我有使用故事板的麻煩。ios 6 prepareForSegue導致黑屏
我通過push segue(其標識符爲pic2profile
)將一個按鈕(在自定義uiviewcell
中)正確連接到場景(ProfileVC
)。 除了在表視圖控制器(HomeVC
),該管理I實現的方法prepareForSegue
細胞:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"pic2profile"]){
ProfileVC *profile = (ProfileVC *)segue.destinationViewController;
NSLog(@"%@", [segue identifier]);
Tweet *tweet = [tweets objectAtIndex:0];
profile.user = tweet.user;
}
}
如文檔中說明的那樣,一旦稱爲segue.destinationViewController
在prepareForSegue
到底應該在結束顯示的視圖控制器(在這種情況下爲ProfileVC
)。 發生什麼是我得到(沒有錯誤!)一個黑色的屏幕和方法viewDidLoad
ProfileVC
不會被調用,雖然對象「配置文件」不爲空。
在故事板中,ProfileVC場景鏈接到其視圖控制器(ProfileVC),並且還設置了Storyboard ID。
我已經試過this但它沒有工作。
您的當前視圖控制器是否由導航控制器管理? (嘗試在'prepareForSegue:'中記錄'self.navigationController'確定。) –
是的。故事板中的HomeVC嵌入在導航控制器中。事實上,當我點擊連接到ProfileVC的按鈕時,我會看到一個黑色屏幕,頂部有一個導航欄(我可以返回到HomeVC)。 – lontra
你是什麼意思現場是與viewController「鏈接」? – AMayes