iOS 5从UIActionSheet按钮加载视图 [英] iOS 5 Load View from UIActionSheet Button

查看:87
本文介绍了iOS 5从UIActionSheet按钮加载视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得了iOS 5的故事板问题。第一个应用程序我正在构建故事板,我喜欢使用它们,但我不能为我的生活弄清楚如何从UIActionSheet按钮加载视图。我让UIActionSheet运行得很好,它加载了一个UIAddressBook选择器,但我想让它切换到一个新的故事板视图控制器。

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.

任何想法?

以下是一些代码:

// 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从storyboard实例化ViewController。其余的与没有Storyboard的其他ViewControllers相同。

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.

这篇关于iOS 5从UIActionSheet按钮加载视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆