我不斷收到錯誤:無法識別的選擇發送到實例的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