iOS 5 从 UIActionSheet 按钮加载视图
有一个 iOS 5 故事板问题。我使用 Storyboard 构建的第一个应用程序,我喜欢使用它们,但我一生都无法弄清楚如何从 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
}
}
Got an iOS 5 storyboard question. First app I'm building with Storyboards and i like using them, but i can not for the life of me figure out how to load a view from a UIActionSheet button. I have the UIActionSheet running just fine and it loads a UIAddressBook picker, but I want to have it switch to a new storyboard view controller.
Any ideas?
Here's some of the code:
// 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
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
[UIStoryboard instantiateViewControllerWithIdentifier:]
方法。您可以在IB的属性检查器中为特定ViewController设置标识符。您使用此标识符作为参数调用上述方法,iOS 会从故事板实例化 ViewController。其余的与其他没有 Storyboard 的 ViewController 相同。Look at the
[UIStoryboard instantiateViewControllerWithIdentifier:]
method. You can set an identifier for specific ViewController in attribute inspector of IB. You call above method using this identifier as a parameter and iOS instantiates the ViewController from storyboard. The rest is the same as other ViewControllers without Storyboard.