tôi tiếp tục nhận được lỗi:Selector không được nhận gửi đến dụ UIViewController
NSInvalidArgumentException', reason: '-[UIViewController setPhotoCellName:]: unrecognized selector sent to instance
khi tôi nhập của tôi chuẩn bị cho cuộc gọi segue. Hiện tại tôi có
TabBarController->NavigationController->TableViewController->TableViewController->ViewController
bằng hình ảnh giao diện người dùng trên đó.
Sự cố xảy ra khi tôi cố gắng tách biệt khỏi bộ điều khiển TableView thứ hai sang ViewController. Tôi có thiết lập segue từ Prototype Cell đến ViewController thực tế. Nó đi vào segue và treo. Tôi đang cố gắng chuyển thuộc tính NSArray
qua số viewController
để có thể sử dụng URL trong đó và hiển thị số UIImage
. PhotoInPlace chứa mảng mà Im đang cố gắng vượt qua. Đây là mã.
myTableViewControllerPhotoLocation.m 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 Mã
@property (nonatomic, strong) NSArray* photoCellName;
FlickrImageViewController.m 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;
}
}
Tôi đã sử dụng kiểu mã này để truyền một mảng trong TVC trước đây Tôi không biết tại sao nó lại rơi vào cái này –