Storyboard」カテゴリーアーカイブ

StoryboardからViewControllerをオブジェクト化

[objc]
//
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"{storyboardファイル名}" bundle:nil];
STHogeViewController *con = [sb instantiateInitialViewController];
//
[/objc]

関連情報 ストーリーボードファイル名
[objc]
//
DataViewController *startingViewController = [self.modelController viewControllerAtIndex:0 storyboard:self.storyboard];
//
[/objc]

[objc]
//
– (DataViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard {
// Return the data view controller for the given index.
if (([self.pageData count] == 0) || (index >= [self.pageData count])) {
return nil;
}

// Create a new view controller and pass suitable data.
DataViewController *dataViewController = [storyboard instantiateViewControllerWithIdentifier:@"DataViewController"];
dataViewController.dataObject = self.pageData[index];
return dataViewController;
}
//
[/objc]