user529543
user529543

Reputation:

UIWebView width 0

The code part:

UIWebView *wb = [[UIWebView alloc] init];
self.examplesView = wb;
[wb release];
examplesView.scalesPageToFit = YES;
[self.view addSubview:examplesView];
NSLog(@"createViewsForRect: %@, examplesView.frame : %@",NSStringFromCGRect(rect), NSStringFromCGRect(examplesView.frame));

The output:

createViewsForRect: {{0, 0}, {320, 480}}, examplesView.frame : {{0, 0}, {0, 0}}

This UIViewController is added later to another controller, where is called a function to load something and I did a log:

examplesView.frame: {{0, 0}, {0, 360}}

Because the width is 0 that's why isn't visible. How to fix it? Why is getting 0 width?

This is an old, inherited code without ARC...

Upvotes: 0

Views: 73

Answers (1)

w____
w____

Reputation: 3605

The first line shall be

UIWebView *wb = [[UIWebView alloc] initWithFrame:rect];

then wb will be initialized with the frame you want.

Upvotes: 1

Related Questions