Ios 在iAction中调用void
我有以下资料:Ios 在iAction中调用void,ios,button,text,label,Ios,Button,Text,Label,我有以下资料: -(void)turnBlue:(DetailVC *) controller { self.Label.text = controller.selected.name; self.selected = controller.selected; [controller.navigationController popViewControllerAnimated:YES]; } 我正在尝试从我的ibaction进入: - (IBAction)pressButton:(id
-(void)turnBlue:(DetailVC *) controller {
self.Label.text = controller.selected.name;
self.selected = controller.selected;
[controller.navigationController popViewControllerAnimated:YES];
}
我正在尝试从我的ibaction进入:
- (IBAction)pressButton:(id)sender {
//filler code here
}
我正在努力
[self turnBlue:selected];
但我收到“不兼容的指针类型发送…”
我试过控制器,我遗漏了哪些细节?应该是这样的:
// Allocate or get already created instance of `DetailVC`
DetailVC *controller = [[DetailVC alloc] initWithNibName..........];
// Pass instance to `turnBlue` function:
[self turnBlue:controller];
turnBlue
只能接受类型为DetailVC
的参数,而您传递的selected
似乎不是类型为DetailVC
,因此您收到的是不可计算的指针类型错误
希望有帮助
selected
应该是DetailVC
的对象。准确完整的错误消息会很有帮助。您的变蓝方法需要DetailVC对象作为参数,而您正在传递selected,这就是您出错的原因。见"永不绝望"的答案。