2011-09-13 33 views
0

我試圖用一個從nib創建的視圖控制器來做一個非常簡單的pushViewController。從Nib推UIViewController時UIWindow沒有設置

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
ServiceDetailViewController *serviceDetail = [[ServiceDetailViewController alloc] initWithNibName:@"ServiceDetailViewController" bundle:nil]; 
serviceDetail.employee = _employee; 

[self.navigationController pushViewController:serviceDetail animated:YES]; 
previousSelectedRow = indexPath; 
} 

如果我的viewDidLoad中或其他地方內恢復其職能內的serviceDetail視圖控制器的窗口爲null。當我在pushViewController之後立即返回它的窗口時,它很好。

我的viewDidLoad是正常的。我打電話超級。

看起來好像這是我忽略的一些愚蠢的東西,我的splitViewController設置有問題,或者xCode 4/ARC中存在一個錯誤。

我知道我可能需要提供更多的代碼,但我希望有人可能有一個想法。

回答

0

viewDidLoad在視圖加載到內存後,但在視圖添加到包括後臺窗口的視圖層次結構之前調用。在添加到窗口之後,viewDidAppear方法被調用。也許你的代碼需要窗口值將在這種方法中更好地工作。

+0

所以我有一個UIButton的子類,我用它來顯示popover。它有一個「演示者視圖」iVar,我分配並呈現彈出窗口。我已經嘗試在viewDidLoad中設置該presenterView,而viewDidAppear和UIWindow始終爲零。這會導致以下錯誤:「Popovers無法從沒有窗口的視圖中呈現。」 – bjtitus

相關問題