ios - 按下附件按钮中 Storyboard 的推送 View

标签 ios objective-c xcode uistoryboard uitableview

我有名为“MainStoryboard_iPhone.storyboard”的 Storyboard,它有 2 个 View 。第一个 View 有一个带有显示按钮的表格单元格。我可以将表格单元格拖放到其他 View 并显示该 View ,但是只有当用户单击附件按钮而不使用 segue 时,我才需要以编程方式执行此操作。 2 个 View 的名称分别是 RootViewController 和 ProviderLookupViewController。目前我已经尝试过此代码但不起作用,当我单击单元格上的附件按钮时会引发错误。注释行是我尝试过的其他内容

-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
    UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
                                                  bundle:nil];
   // ProviderLookupViewController* vc = [sb instantiateViewControllerWithIdentifier:@"ProviderLookupViewController"];
    UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"ProviderLookupViewController"];
     [self presentModalViewController:vc animated:YES];
    //[self.navigationController pushViewController:vc animated:YES];

}

最佳答案

如果我是正确的:

1)从您的问题来看,您似乎有一个带有两个 View Controller 的 Storyboard,第一个是 UITableViewController,另一个是 UIViewController 的子类。

2)当用户单击公开按钮时,您希望呈现第二个 View 。

鉴于您使用 Storyboard而不是 nib 文件,我建议您使用 segue,它无需编写代码即可解决您的问题。

表格 View 单元格可以有两个 segue,一个如果您选择单元格,另一个如果您选择附件按钮。控制从附件按钮到第二个 View Controller 的拖动,而不是从单元格中进行控制拖动,当菜单出现时,您必须在辅助操作下方选择一个选项,而不是在选择序列下方

enter image description here

表格 View 的原型(prototype)单元格必须启用公开附件。从实用程序 Pane (右侧)执行此操作。配件不能没有做到这一点。图片附件是详细信息披露。

enter image description here

实用程序 Pane 还可以让您进行转场。不过,请使用辅助 Action ,图片来自我的一个项目。

enter image description here

关于ios - 按下附件按钮中 Storyboard 的推送 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18484274/

相关文章:

swift - 如何防止点击节点时崩溃

ios - Xcode 7.1 "The request timed out."错误

ios - 在不破坏 xcodebuild 存档的情况下将 os x 工具构建为 iOS 项目的一部分?

iphone - Xcode - 创建 csv/电子表格文件

objective-c - 从 Objective-C 工厂方法创建 Swift 实例

xcode - 我的 Interface Builder 库中的核心数据实体在哪里?

ios - iOS 4.3.4 中是否可以使用离线 HTML5 应用程序?

ios - 如何在函数之外获取加速度计数据?

ios - 在我的 Controller 中未调用 supportedInterfaceOrientations

ios - TableView 不显示标签 ios