我想創建一個非常簡單的應用程序,雖然我卡在幾天同樣的問題...... 我使用故事板和我目前的設置是這樣的: storyboardIOS - 使用容器,表視圖和詳細視圖 - 如何保持詳細視圖裏面容器
我的目標是保持在「項目視圖控制器」中的所有內容除了容器內發生的情況。 「註釋表視圖」顯示我的容器內確定,但在tableview中攻一小區時,「註釋顯示視圖」覆蓋整個屏幕(請注意,在故事板,它繼承了正確的大小)。 這是我的「prepareForSegue」的樣子(我試過實例的大小固定在tableview中大小):
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"showComment"]){
CommentShowViewController *csvc = [segue destinationViewController];
[[csvc view] setFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height)];
NSIndexPath *path = [commentsTable indexPathForSelectedRow];
Comment *c = [aCommentsList objectAtIndex:[path row]];
[csvc setCurrent:c];
}
}
任何想法如何,我可以使這項工作?
感謝, 喬納森
謝謝!它很棒! –
關於此解決方案的一個問題。我遇到過類似的問題,當我在容器和初始tableviewcontroller之間粘貼額外的uinavigationcontroller時,它抱怨我在prepareForSegue方法中傳遞的屬性缺失。這是因爲它試圖將數據傳遞給navigationcontroller而不是目標uitableviewController。這裏有沒有一個步驟? – sapatos
'segue.destinationViewController'可能會返回'UINavigationController'。您需要改用'segue.destinationViewController.topViewController'。 – Jzon