问题描述
我是Objective-C的新手,觉得学习很重要。我给自己以下挑战:
我有一个NSSplitViewController设置,每个视图有两个类; (i)SourceViewController:NSViewController和(ii)DetailViewController:NSViewController。
通过选择SourceViewController的NSTableView行,我想在SourceViewController内的ImageView中更改图像
我正在尝试从SourceViewController访问的DetailViewController中有一个实例类方法:
-(void) imageSelected: (NSString*) name{
self.imageView.image = [NSImage imageNamed:name];
}
为了获得访问权限,我通过NSSplitViewController超类创建了一个指向DetailViewController类实例的指针。因此,我在树上向上再向下到DetailViewController:
//gets the row number that was selected
-(void) tableViewSelectionDidChange:(NSNotification *)notification{
NSLog(@"%ld",[[notification object] selectedRow]);
NSInteger row = [[notification object] selectedRow];
//get access to the parent view controller
//NSSplitViewController *splitCV = self.parentViewController;
NSSplitViewController *splitCV = ((NSSplitViewController *)self.parentViewController);
NSViewController *imageVC = splitCV.childViewControllers[1];
NSLog(@"%@",imageVC.className); //detail view controller
//***** HERE'S THE PROBLEM******
imageVC.imageSelected(self.pictures[row]); //<- imageSelect isn't recognised
}
但是,这不起作用,因为自动完成功能无法识别imageVC指向的功能。打印imageVC.className输出,显示名称为'DetailViewController'。
我在做什么错,我该如何解决?
预先感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)