當用戶在UITableViewController中選擇一行時,我想繼續瀏覽另一個viewController並將其UIImageView設置爲以前設置的圖像。目前,我正在使其具有通用性 - 始終顯示/images/en.jpeg。segue.destinationViewController - NSInvalidArgumentException
flickrTVC.m(的UITableViewController):
@implementation flickrTVC
...
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"showPhoto"])
UIImage *photo = [UIImage imageWithContentsOfFile:@"images/en.jpeg"];
[segue.destinationViewController setDisplayedPhoto:photo];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"showPhoto" sender:self];
}
我有 - (無效)setDisplayedPhoto:(的UIImage *)圖像;(它將self.photo設置爲圖像)在我的photoViewController.h(segue.destinationViewController)中。 我在下一行越來越
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setDisplayedPhoto:]: unrecognized selector sent to instance 0x1f5c4a60'
: [segue.destinationViewController setDisplayedPhoto:照片]。即使執行空白,錯誤仍然顯示。 我是新來的Objective-C,可能,我只是搞砸了一些事情。
任何幫助,將不勝感激。 謝謝!
新手錯誤...我沒有將ViewController的類從generic改爲photoViewController!感謝您的快速響應,我很感激! – Krzysiek 2012-07-17 02:48:22