Iphone ipad上的UIWebView初始化崩溃

Iphone ipad上的UIWebView初始化崩溃,iphone,ipad,uiwebview,crash,Iphone,Ipad,Uiwebview,Crash,我使用以下代码初始化UIWebView的实例: -(void)viewDidLoad { [super viewDidLoad]; UIWebView *webView; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 768, 964)]; //crash

我使用以下代码初始化UIWebView的实例:

-(void)viewDidLoad {

    [super viewDidLoad];

    UIWebView *webView;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
      webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 768, 964)]; //crash
    } else {
      webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 380)];
    }   
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   // Return YES for supported orientations
   return YES;
}
这很奇怪,上面的代码是在iphone模拟器上运行的,但它会在ipad模拟器上崩溃。我的xcode是3.2.4。你能提供一些线索吗?提前谢谢

事故日志:

0 0x031b5574在flushCaches中
1 0x031b38fc在remethodizeClass中
2 0x031b60ea在读取图像中
3 0x031c3784在地图图像中锁定
#4 0x031b5724在地图图像中锁定
#5 0x8fe03f2d在 __dyld_ZN4DYLDL18NotifyBatchPartial17DYLD_图像_状态BPPKCS0_jPK15dyld_图像_信息

6 0x8fe0decd在\uuuuu dyld\uuuuu ZN11ImageLoader4linkERKNS\u11LinkContexterkns\u10rPathChaine中
7 0x8fe056af in uuu dyld uu zn4dyld4linkedp11ImageLoaderRkns0_10RPathChainE
uu dyld dlopen
8 0x8fe0b242 in uu dyld dlopen
9 0x9754a868 in dlopen
10 0x0063b8e6 in initWebUILocalStorageSupport
11 0x0063A0060D6 in-[UIWebView\uWebViewCommonInit:
;12 0xUI3AD:]-[WebViewController] viewDidLoad]位于WebViewController.m:55
#14 0x00525f85英寸 -[UIViewController视图]
#15 0x0052439f in-[UIViewController内容滚动视图]
#16 0x00532查看in-[UINavigationController _计算和应用CrollContentInsertDeltaForviewController:
17 0x00531f40 in-[UINavigationController(布局视图控制器):
18 0x00533f39 in-[UINavigationController(u startTransition:fromViewController:to ViewController:
19 0x0052dfa1 in-[UINavigationController(u StartDeferredTransition,如果需要的话)
20 0x73C8a in-[UILayoutContainerView布局子视图]
#21 0x02b10916 in-[CALayer布局子层]
#22 0x02b10625 in-CALayer布局需要
#23 0x02b3b0e7 in-[CALayer 需要布局]
#24 0x00527296 in-[UIViewController 窗口:WillAnimateRotationInterface方向:持续时间:

25 0x004afef1 in-[UIWindow\u setRotatableClient:TooOrientation:duration:force:
26 0x00736425 in-[UIWindowController转换:从ViewController:toViewController:target:DiEndSelector:
27 0x005297ac in-[UIViewController presentModalViewController:带转换:]
28 0x00522e70 in -[UIViewController-tryRecursivelyPresentModalViewController:withTransition:
29 0x0052901d in-[UIViewController-presentModalViewController:withTransition:
30 0x0002b8b4 in -[TweetViewController showLocation:]位于TweetViewController.m:608
#31 0x0048dcee in-[UIApplication sendAction:to:from:forEvent:
#32 0x0050743e in-[UIControl sendAction:to:forEvent:
#33 0x005098c0 in-[UIControl(内部)#发送操作预防:withEvent:
#34 0x0050846d in-[UIControl触摸:withEvent:]
#35 0x0071aaad英寸 _UIgestureRecognitizerUpdateObserver
#36 0x03016a52 in(uu cfrunloopDoObserver
#37 0x02fe3345 in cfrunloopSpecific
#38 0x02fe28a8 in cfrunloopinMode

GSEventRunModal中的39 0x034d089d
在UIApplicationMain中的GSEventRun中的40 0x034d0962
中的41 0x00498372
42 0x00002dd8在主管道的主管道中。m:14

您是否更改了WebView initWithFrame?这不是WebView的错,这是使用框架创建它的正确方法。
您可以发布控制器的其余部分吗?

请提供崩溃日志。代码本身看起来很好。@Schot,感谢格式化看起来是其他原因导致了崩溃…,同意Stream Trout。无论如何,如果是指针,通常最好将局部变量初始化为零。@Steam&SegFault,感谢重播。附日志。I刚发现AutorotateToInterfaceOrientation方法将首先调用,然后在控制器初始化期间调用viewDidLoad方法。您认为我为ipad错过的任何设置是否指定了自动旋转的要求?谢谢。我删除了AutorotateToInterfaceOrientation方法,然后可以创建webView而不会崩溃。我只是想我无法将我的应用程序从iphone移植到ipad,所以可能我在代码中遗漏了ipad的一些关键设置,你能提供一些线索吗?谢谢。尝试将webview作为类属性(保留,非原子)并将其添加到ib中。之后更改其大小应该会更容易。