Xcode显示UITableRowSelection后的UIAlertView?

这是我的第一个问题,对不起,如果有什么不对

那么我想创build一个视图,我可以从表视图中select一个朋友,然后它应该说一个UIAlertView的数量和邮件,但我不知道如何做这个朋友列表是从一个XML文件在我的网站上,然后parsing一个表格上显示一个自定义的单元格devise

这是创build每个单元格的代码

- (UITableViewCell *)tableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = (UITableViewCell *)[self.messageList dequeueReusableCellWithIdentifier:@"ContactListItem"]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ContactListItem" owner:self options:nil]; cell = (UITableViewCell *)[nib objectAtIndex:0]; } NSDictionary *itemAtIndex = (NSDictionary *)[messages objectAtIndex:indexPath.row]; UILabel *userLabel = (UILabel *)[cell viewWithTag:2]; userLabel.text = [itemAtIndex objectForKey:@"user"]; return cell; } 

感谢圣地亚哥

你必须实现didSelectRowAtIndexPath:方法。

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *itemAtIndex = (NSDictionary *)[messages objectAtIndex:indexPath.row]; NSString *name = [itemAtIndex objectForKey:@"user"]; NSString *email = [itemAtIndex objectForKey:@"email"]; NSString *phone = [itemAtIndex objectForKey:@"phone"]; NSString *messageStr = [NSString stringWithFormat:@"Email : %@\nPhone : %@", email, phone]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:name message:messageStr delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; } 

– (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath是您需要实现的方法。 这是假设您正在呈现表视图的视图是表视图的委托。

 -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //Alert view logic happens here getting all the cell information }