0

代码部分:

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));

输出:

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

这个 UIViewController 稍后被添加到另一个控制器中,在那里调用了一个函数来加载一些东西,我做了一个日志:

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

因为宽度为 0,所以不可见。如何解决?为什么宽度为 0?

这是一个没有 ARC 的旧的继承代码......

4

1 回答 1

1

第一行应为

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

然后wb将使用您想要的框架进行初始化。

于 2013-01-17T09:25:24.620 回答