2012-07-20 61 views
-1

良好问候,并寻找信息,但没有找到答案,我有一个按某些细胞是有与显示每个单元的个性化数据的alertview一个实现代码如下。 这是代码:的UITableView与UIAlertView中 - (UITableView的带UIAlertView中)

-(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]; 

} 

} 

你看,如果你按上面写着约翰UIAlertView中出现,如果我按佩德罗出现另一个UIAlertView中,如果每个单元的电池,但按该小区的alertview不会出现细胞我错了,希望我可以从现在的感谢帮助。

INGLES - 谷歌翻译

良好问候,并希望信息,但没有找到答案我有一个tableview中,我要你按一个细胞似乎可以肯定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]; 

} 

} 

你看,如果我按上面写着娟看到一个UIAlertView中和细胞,如果我按另一种细胞出现佩德罗UIAlertView中,如果每个细胞,但按电池不alertview我的出现“M错了,我希望我能帮助并不能通过找到解决方案。

+0

仍然无法正常工作,这里的链接http://stackoverflow.com/q/11587330/1539443 – Geovany 2012-07-20 22:09:18

回答

1

您不能测试平等==字符串,所以你message == @"Juan"测试总是失败。使用[message isEqualToString:@"Juan"]来代替。

+0

仍然无法正常工作,这里的链接,但仍感谢http://stackoverflow.com/q/11587330/1539443 – Geovany 2012-07-20 21:47:46

+0

因为我有一个疑问,你仍然不能工作,我希望在这里:(链接http://stackoverflow.com/q/11587330/1539443 – Geovany 2012-07-20 22:23:01