在IBAction中调用void

时间:2014-07-17 03:39:18

标签: 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)sender {
//filler code here
}

我正在尝试

[self turnBlue:selected];

但是我得到'不兼容的指针类型发送......'

我试过控制器,我错过了哪些细节?

1 个答案:

答案 0 :(得分:0)

应该是这样的:

// 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类型,因此您收到无法指针类型错误

希望它有所帮助!