2012-03-13 23 views
6

Tôi đang sử dụng một UISplitViewController trên ARC nhưng nó dường như bị đâm sau một vài sự kiện xoay:UISplitViewController EXC_BAD_ACCESS về luân chuyển sử dụng 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 

Ngoài ra, khi tôi khởi động ứng dụng, tôi nhận được lỗi này:

Splitview controller <PUCSplitViewController: 0x36c290> is expected to have a master view controller before its used! 

Điều gì tôi đã bỏ lỡ? Tôi thiết lập nó rất giống với dự án ví dụ mà Apple cung cấp.

Cũng đâm đôi khi chuyển đổi quan điểm chi tiết:

- (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 

Dưới đây là làm thế nào tôi có thể tạo các UISplitViewController trong applicationDidFinishLoading:

PUCSplitViewController *splitPUC = [[PUCSplitViewController alloc] init]; 
self.mainSplitViewController = splitPUC; 
[self.window addSubview:self.mainSplitViewController.view]; 
[self.window makeKeyAndVisible]; 

Ý tưởng?

+0

Đăng ứng dụng của bạnDidFinishLoading code. – fbernardo

+0

Cảm ơn, chỉ cần thêm nó. –

+0

Vì vậy, bộ điều khiển chia tách của bạn không có bộ điều khiển xem khi ứng dụng bắt đầu? Bởi crashlog tôi đặt cược các đại biểu uisplitviewcontrolller đã được phát hành. Hãy thử sử dụng zombie. – fbernardo

Trả lời

6

cho các lỗi

is expected to have a master view controller before its used! 

,

bạn cần phải thiết lập các đại biểu SAU bạn thiết lập bộ điều khiển xem cho splitviewcontroller.

Xem Use Your Loaf blog from April 6th, 2012 (Không, nó không phải của tôi).

+0

Cảm ơn bạn, tôi tình cờ gặp vấn đề tương tự và vấn đề là tôi đã không đặt đại biểu cho bộ điều khiển xem chi tiết mới của tôi. Câu trả lời của bạn dẫn đường ... –

Các vấn đề liên quan