ios - 无法识别的选择器发送到实例 UITableView 单元格推送到 TabbarController

标签 ios objective-c uitableview segue uistoryboardsegue

我只是尝试将 mid 发送到 customerDetailviewcontroller,然后 segue 首先进入 tabbar Controller 。

有我的prepareforsegue方法

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        ApiClass *apiClass = [self.customerCards objectAtIndex:indexPath.row];
        CustomerDetailViewController *customerDetailViewController = (CustomerDetailViewController *)segue.destinationViewController;
        customerDetailViewController.mid = apiClass.mid;



    }
}

_mid NSString * @"1642"

那是错误。

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController setMid:]: unrecognized selector sent to instance 0x126e53580'
*** First throw call stack:
(0x1838d6530 0x1948ac0e4 0x1838dd5f4 0x1838da3ac 0x1837dec4c 0x1000ae2b4 0x1886b401c 0x18820ce14 0x1882ca6dc 0x188166b8c 0x1880d85f0 0x18388ed98 0x18388bd24 0x18388c104 0x1837b91f4 0x18cbdb6fc 0x18814a10c 0x1000e2b08 0x194f2aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是我从 json 获取的数据。所以它不是 nil。

http://prntscr.com/6lzjkd

最佳答案

我弄清楚了。主要问题是我将 segue 推送到标签栏 Controller 。我用这段代码修复了它。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDetail"]) {
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    ApiClass *apiClass = [self.customerCards objectAtIndex:indexPath.row];
    UITabBarController *tabBarController = [segue destinationViewController];
    CustomerDetailViewController *customerDetailViewController = (CustomerDetailViewController *)[[tabBarController viewControllers]objectAtIndex:0];
    customerDetailViewController.mid = apiClass.mid;



}

关于ios - 无法识别的选择器发送到实例 UITableView 单元格推送到 TabbarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29302805/

相关文章:

iphone - IOS Core蓝牙外设连接请求

ios - 如何以编程方式更改布局边距

ios - 如何使用对象属性上的谓词过滤 NSArray

iphone - 如何阻止willTerminate方法的调用?

iphone - NSFetchedResultsController 添加实体在 tableView 中插入空白行

ios - 类型 'Result<Any, AFError>' 的值没有成员 'value'

iphone - 如何将 UIToolbar 添加到 UIViewController?

ios - 如何在 UITableView 中填充标题单元格

ios - didSelectRowAtIndexPath 被调用但不 prepareForSegue

ios - 返回的 UITextField 框架宽度太短?