首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >prepareForSegue for TabBarController

prepareForSegue for TabBarController
EN

Stack Overflow用户
提问于 2015-09-28 08:32:25
回答 1查看 182关注 0票数 1

我试图使用Objective将数据从我的ViewController传递到TabBarController。我试图将一些数据分配给"bottomTabEventList“(这是我的自定义TabBarController类的属性)。不幸的是,我的程序通过提供未识别的选择器实例错误/警告而崩溃。

在TabBarController类的自定义头中,名为BottomTabview:

代码语言:javascript
复制
@interface BottomTabView : UITabBarController <UITabBarControllerDelegate>

@property(strong,nonatomic)EventList *bottomTabEventList;

@end

和ViewController.m中的prepareForSegue方法

代码语言:javascript
复制
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    BottomTabView *btw = [segue destinationViewController];

    //checking
    if(btw == nil)
        NSLog(@"btw in viewController is nil");
    else
        NSLog(@"btw in viewController is NOT nil");

    if(self.eventList.eventList == nil)
        NSLog(@"eventList in viewController is nil");
    else
        NSLog(@"eventList in viewController is NOT nil"); //end of checking

    btw.bottomTabEventList = self.eventList; //This is where crash appears
}

准确的坠机日志是:

-ViewController setBottomTabEventList::未识别的选择器发送到实例0x7fe923c6ba00 *终止应用程序,原因是'NSInvalidArgumentException',原因:'-ViewController setBottomTabEventList::未识别的选择器发送到实例0x7fe923c6ba00‘

Segue是从ViewController到BottomTabView,它的类型是“现在模式”。如果你能帮我/指导我,我会非常感激的。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-09-28 08:48:54

问题似乎是,btw实际上不是BottomTabView类型的,只是一个UIViewController,因此崩溃日志提供:

ViewController setBottomTabEventList::发送到实例的未识别选择器

因为UIViewController不知道BottomTabEventList是什么。

您需要确保btw实际上是一个BottomTabView实例。

稍微反省一下,我敢打赌这句话不会涉及到以下内容:

代码语言:javascript
复制
  if ([btw isKindOfClass:[BottomTabView class]]){
 btw.bottomTabEventList = self.eventList; 
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32818735

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档