无法识别的选择器已发送到实例UIViewController [英] Unrecognized Selector Sent to Instance UIViewController

查看:79
本文介绍了无法识别的选择器已发送到实例UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到错误消息:

NSInvalidArgumentException",原因:-[UIViewController setPhotoCellName:]:无法识别的选择器已发送到实例

NSInvalidArgumentException', reason: '-[UIViewController setPhotoCellName:]: unrecognized selector sent to instance

当我输入准备进行电话通话时.目前我有

when I enter my prepare for segue call. Currently I have

TabBarController-> NavigationController-> TableViewController-> TableViewController-> ViewController

TabBarController->NavigationController->TableViewController->TableViewController->ViewController

上面带有UI图像.

当我尝试从第二个TableView控制器切换到ViewController时,会发生问题.我有从原型单元到实际ViewController的segue设置.它进入segue并崩溃.我试图将NSArray属性传递给viewController,以便能够在其中使用URL并显示UIImage. PhotoInPlace包含Im试图传递的数组.这是代码.

The problem occurs when I try to segue from the second TableView controller to the ViewController. I have the segue setup from the Prototype Cell to the actual ViewController. It enters the segue and crashes. I am trying to pass an NSArray property over to the viewController to be able to use a URL in it and display the UIImage. PhotoInPlace contains the array that Im trying to pass. Here is the code.

myTableViewControllerPhotoLocation.m代码

myTableViewControllerPhotoLocation.m Code

#import "myTableViewControllerPhotoLocation.h"
#import "FlickrImageViewController.h"

@interface myTableViewControllerPhotoLocation ()
@end

@implementation myTableViewControllerPhotoLocation
@synthesize photoInPlace = _photoInPlace; //Contains NSArray to pass


-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"Photo Display"]){
        NSIndexPath* indexPath = [self.tableView indexPathForCell:sender];
        NSLog(@" Dicitonary = %@", [self.photoInPlace objectAtIndex:indexPath.row]); //Returns the picked cell
        NSLog(@"%@", [self.photoInPlace class]); //returns NSArray
        NSLog(@"%@", [self photoInPlace]); //Returns the array

        [segue.destinationViewController setPhotoCellName:[self.photoInPlace objectAtIndex:indexPath.row]]; 
        //Crashes HERE!
    }
}

FlickrImageViewController.h代码

FlickrImageViewController.h Code

@property (nonatomic, strong) NSArray* photoCellName;

FlickrImageViewController.m代码

FlickrImageViewController.m Code

#import "FlickrImageViewController.h"

@interface FlickrImageViewController ()
@end

@implementation FlickrImageViewController
@synthesize photoCellName = _photoCellName; //property declared in header


-(void) setPhotoCellName:(NSArray *)photoCellName{
    if(!_photoCellName)
        _photoCellName = [[NSArray alloc] initWithArray:photoCellName];
    else {
        _photoCellName = photoCellName;
    }
}

推荐答案

您认为目的地是FlickrImageViewController中的对象,但应用程序不是.查看在情节提要中为该控制器分配的类;根据错误,它是一个空的UIViewController.

You believe that your destination is an object from the FlickrImageViewController but the app doesn't. Look at the class you have assigned that controller in your storyboard; according to the error, it's a bare UIViewController.

这篇关于无法识别的选择器已发送到实例UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆