我正在尝试使用 SCLAlertView 库在您单击表格 View 单元格中的按钮时显示警报 View 。我在我的 tableviewcell.m 中这样展示它:
- (IBAction)showSuccess:(id)sender {
SCLAlertView *alert = [[SCLAlertView alloc] init];
[alert addButton:@"First Button" target:self selector:@selector(firstButton)];
[alert addButton:@"Second Button" actionBlock:^(void) {
NSLog(@"Second button tapped");
}];
[alert showSuccess:self title:@"test" subTitle:@"test" closeButtonTitle:@"test" duration:0.0f];
}
但是当我点击按钮时,应用程序崩溃并给我这个错误:
[TableViewCell addChildViewController:]: unrecognized selector sent to instance 0x126e1bc90
它还在我实际显示警报的行上给了我这个警告:
Incompatible pointer types sending 'TableViewCell *' to parameter of type 'UIViewController *'
我猜我无法从我的 Table View Cell 中显示 View Controller,但我该如何解决这个问题?
最佳答案
您必须将单元格的父 View Controller 添加为 childViewController。
因此,在单元格中添加一个委托(delegate),将其附加到 TableViewController 中,然后在单元格委托(delegate)触发时从 TableViewController 调用警报。
关于ios - 从 UITableViewCell : addChildViewController unrecognized selector sent to instance 呈现 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29143518/