我不断收到错误:无法识别的选择发送到实例的UIViewController
NSInvalidArgumentException', reason: '-[UIViewController setPhotoCellName:]: unrecognized selector sent to instance
当我输入我的电话赛格瑞准备。目前我有
TabBarController->NavigationController->TableViewController->TableViewController->ViewController
与它的UI图像。
当我尝试从第二个TableView控制器切换到ViewController时发生问题。我有从Prototype Cell到实际ViewController的segue设置。它进入了继续和崩溃。我正尝试将NSArray
媒体资源转交给viewController
,以便能够使用其中的网址并显示UIImage
。 PhotoInPlace包含我试图通过的数组。这是代码。
myTableViewControllerPhotoLocation.m代码
#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代码
@property (nonatomic, strong) NSArray* photoCellName;
FlickrImageViewController.m代码
#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;
}
}
我使用的代码的这种风格通过在现有TVC数组我不知道为什么它在这一个 – 2012-08-03 21:36:43