반응형
to send some viewcontroller with navigation controller,
you can not send with DetailViewController2 *destViewController = segue.destinationViewController (X)
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowDetails"]) {
// [segue returns a UINavigationController and the controller you
// want is embedded in the navigation controller
UINavigationController *navigationController = [segue destinationViewController];
// We want the top view controller from the navigationController
// and don't forget the cast
DetailViewController2 *detailViewController = (DetailViewController2 *)navigationController.topViewController;
// Removed redundant line as there was no need to create local variable for
// one time use
NSUInteger row = [[self.tableView indexPathForSelectedRow] row];
// There was no need to have these two on on separate lines
GameInfo *gameInfoObject = [GamesInfoArray objectAtIndex:row];
// To add a fail safe you could wrap this in respondsToSelector
// just in the event that the topViewController isn't a DetailViewController2
if ([detailViewController respondsToSelector:@selector(setDetailArray:)]) {
// Note the lowercase for detailArray see comments above this property.
detailViewController.detailArray = @[gameInfoObject.HomeTeam, gameInfoObject.AwayTeam];
}
}
}
반응형
'모바일개발(Mobile Dev) > IOS개발(ObjectC)' 카테고리의 다른 글
ABOUT UIBarButtonItems (0) | 2015.12.15 |
---|---|
Failed to allocate data stores for 854269899 rows in section 0. Consider using fewer rows" (0) | 2015.12.15 |
How to Submit Your App (0) | 2015.12.14 |
splash screen for all types of iPhones in XCode 6.1? (0) | 2015.12.13 |
background thread in iOS (0) | 2015.12.12 |