【问题标题】:iOS 5 Load View from UIActionSheet ButtoniOS 5 从 UIActionSheet 按钮加载视图
【发布时间】:2012-02-22 07:41:48
【问题描述】:

有一个 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
    }
}

【问题讨论】:

    标签: ios5 uiactionsheet


    【解决方案1】:

    查看[UIStoryboard instantiateViewControllerWithIdentifier:] 方法。您可以在 IB 的属性检查器中为特定的 ViewController 设置标识符。您使用此标识符作为参数调用上述方法,iOS 从情节提要中实例化 ViewController。其余的和其他没有 Storyboard 的 ViewController 一样。

    【讨论】:

    • 完美运行!使用此代码:AddPersonViewController *addPerson = [self.storyboard instantiateViewControllerWithIdentifier:@"AddPerson"]; [self.navigationController pushViewController:addPerson animated:YES];
    猜你喜欢
    • 2012-09-21
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多