17

我有一个带有书名的 UITableView。我还有一个视图(AddAndEditBookViewController)来输入有关书籍的信息。当我单击表格导航栏上的“+”时,我想打开我的 AddAndEditBookViewController。如果我在单独的 nib 文件中创建表格,我知道该怎么做,但是如果我的视图是在情节提要中创建的,我该怎么做(没有 segues ......此时更多用于学习目的)。

我读到我可以使用情节提要中的 instantiateViewControllerWithIdentifier 方法,但是如何找到我的视图控制器的 id?我尝试查看情节提要的 XML 表示,但我似乎没有找到它......

这是尝试打开模式视图的代码。

- (void)insertNewObject:(id)sender
{
    AddAndEditBooksViewController * addViewController = (AddAndEditBooksViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"gH8-2m-MXv"];
    [addViewController setDelegate:self];
    [addViewController setModalPresentationStyle:UIModalPresentationFormSheet];
    [self presentViewController:addViewController animated:YES completion:NULL];
}

我的具体问题是:我应该使用什么标识符?它在哪里指定或我如何手动指定它?

谢谢!

4

1 回答 1

35

它位于 IB 的 Identity Inspector 选项卡下。它被称为“故事板 ID”。你可以给它任何你想要的唯一名称。

于 2012-10-09T05:48:20.913 回答