我有一个表格视图,我希望您按下某个单元格会显示带有每个单元格个性化数据的Alertview。这是代码:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *message=[NSString stringWithFormat:@"%@", [tableViewData objectAtIndex:indexPath.row]];
if (message == @"Juan") {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Alerta" message:@"Ciudad de México" delegate:self cancelButtonTitle:@"Cerrar" otherButtonTitles:nil];
[alert show];
}
}
[您看到我是否按了Juan看到的UIAlertView单元格,如果我按了另一个单元格,则出现了Pedro UIAlertView,如果对于每个单元格但按此单元格都没有出现在Alertview中,我错了,我希望我能提供帮助并且不能从中找到解决方案。
您无法使用==测试字符串的相等性,因此您的测试message == @"Juan"
将始终失败。请改用[message isEqualToString:@"Juan"]
。