我使用ARC
一個UISplitViewController
但似乎很少旋轉事件後要崩潰:UISplitViewController EXC_BAD_ACCESS上旋轉使用ARC
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x80069f69
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x32461f78 objc_msgSend + 16
1 UIKit 0x3588b280 -[UISplitViewController _calculateDelegateHiddenMasterOrientations] + 52
2 UIKit 0x3588cca8 -[UISplitViewController setViewControllers:] + 1344
3 PUC 0x000d0a42 0x1000 + 850498
4 UIKit 0x35644ade -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 938
5 UIKit 0x356be7a4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 152
此外,當我啓動應用程序,我得到這個錯誤:
Splitview controller <PUCSplitViewController: 0x36c290> is expected to have a master view controller before its used!
我錯過了什麼?我將其設置得非常類似於Apple提供的示例項目。
而且有時崩潰切換詳細視圖時:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Clicked Asset
Asset *asset = [items objectAtIndex:indexPath.row];
UIViewController *detailViewController = nil;
// See what asset we are on
if ([asset.title isEqualToString:@"News"]) {
News2 *news = [[News2 alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController *newsNav = [[UINavigationController alloc] initWithRootViewController:news];
detailViewController = newsNav;
} else if ([asset.title isEqualToString:@"Photos"]) {
PhotosiPad *photos = [[PhotosiPad alloc] init];
UINavigationController *photosNav = [[UINavigationController alloc] initWithRootViewController:photos];
detailViewController = photosNav;
}
// Update the split view
[PUCAppDelegate instance].mainSplitViewController.viewControllers = [NSArray arrayWithObjects:self.navigationController, detailViewController, nil];
// Dismiss the popover if it's present.
if (popoverController != nil) {
[popoverController dismissPopoverAnimated:YES];
}
}//end
這裏是我創建UISplitViewController
在applicationDidFinishLoading
:
PUCSplitViewController *splitPUC = [[PUCSplitViewController alloc] init];
self.mainSplitViewController = splitPUC;
[self.window addSubview:self.mainSplitViewController.view];
[self.window makeKeyAndVisible];
想法?
發佈您的applicationDidFinishLoading代碼。 – fbernardo 2012-03-13 02:01:58
謝謝,剛添加它。 – 2012-03-13 03:59:05
因此,您的splitviewcontroller應用程序啓動時沒有viewcontrollers?通過崩潰日誌,我敢打賭,uisplitviewcontrolller代表被釋放。請嘗試使用殭屍。 – fbernardo 2012-03-13 08:23:35