收到一个iOS 5故事板问题。我用Storyboards构建的第一个应用程序,我喜欢使用它们,但我一辈子都不知道如何从UIActionSheet按钮加载视图。我让UIActionSheet运行得很好,它加载了一个UIAddressBook选择器,但我想让它切换到一个新的故事板视图控制器。
有什么想法吗?
以下是一些代码:
// Specify what to do when a user selects a button from the personSelectQuery
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
[self showAddressPicker];//This works just fine to show the address book
} else if (buttonIndex == 1){
[self showAddPersonView];//This is the custom storyboard view i want to load
}
}
查看[UIStoryboard instantiateViewControllerWithIdentifier:]
方法。您可以在IB的属性检查器中为特定的ViewController设置一个标识符。您使用该标识符作为参数调用上述方法,iOS将从情节提要中实例化ViewController。其余部分与没有情节提要的其他ViewControllers相同。