【发布时间】:2012-08-01 23:11:01
【问题描述】:
我不断收到错误:
NSInvalidArgumentException',原因:'-[UIViewController setPhotoCellName:]:无法识别的选择器发送到实例
当我进入准备转场呼叫时。目前我有
TabBarController->NavigationController->TableViewController->TableViewController->ViewController
上面有一个 UI 图像。
当我尝试从第二个 TableView 控制器转移到 ViewController 时,会出现问题。我有从 Prototype Cell 到实际 ViewController 的 segue 设置。它进入segue并崩溃。我正在尝试将NSArray 属性传递给viewController,以便能够在其中使用URL 并显示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 中传递了一个数组,我不知道为什么它会在这个上崩溃
标签: objective-c xcode uiviewcontroller uitableview segue