使用segue传递字符串会导致崩溃

时间:2016-02-02 17:14:52

标签: ios objective-c segue

我正在尝试将字符串从ViewController (VC)传递到CollectionViewController (CVC) 我在VC上有一个UIButton,其中show的触发segue链接到CVC。 在我的VC中,我有prepareForSegue如下

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"gotoImages"]) {
        CQTaskPhotosCVC *vc = segue.destinationViewController;
        vc.queueID = _idCode;
    }
} 

在我的CVC.h中

@interface CQTaskPhotosCVC : UICollectionViewController
@property (nonatomic, strong) NSString *queueID;
@end

然后是我得到的错误

  

2016-02-02 12:05:45.015 CactusQueue [41739:6063627] - [UICollectionViewController setQueueID:]:无法识别的选择器发送到实例0x12836e410

     

2016-02-02 12:05:45.017 CactusQueue [41739:6063627] ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UICollectionViewController setQueueID:]:无法识别的选择器发送到实例0x12836e410'< / p>

我之前使用segues在VC之间传递了数据,但我从未遇到过这个问题。删除vc.queueiD = _idCode;不会导致崩溃,所以我不知道我是否只是忽略了一些愚蠢或什么。 怎么办?

2 个答案:

答案 0 :(得分:0)

如果您已在自定义类部分中输入CQTaskPhotosCVC作为类,请在界面构建器的右侧检查:

enter image description here

答案 1 :(得分:0)

您的错误:

[UICollectionViewController setQueueID:]: unrecognized selector sent to instance 

它表示类UICollectionViewController的对象正在调用它不知道的方法setQueueID:

因此,您真正的问题是,在您的情节提要中,您没有将自定义类CQTaskPhotosCVC设置为UICollectionViewController

相关问题