Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在iAction中调用void_Ios_Button_Text_Label - Fatal编程技术网

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,这就是您出错的原因。见"永不绝望"的答案。