Xcode在UITableRowSelection之后显示UIAlertView吗? [英] Xcode show UIAlertView after UITableRowSelection?

查看:43
本文介绍了Xcode在UITableRowSelection之后显示UIAlertView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题,对不起,如果出现问题

this is my first question, sorry if something is wrong

好吧,我正在尝试创建一个视图,在该视图中我可以从表格视图中选择一个朋友,然后应该在UIAlertView上说出数字和邮件,但我不知道该怎么做朋友列表是从我网站上的xml文件中获得的,然后解析为带有自定义单元格设计的表格上显示的

Well I'm trying to create a view in which i can select a friend from a table view and then it should say the number and the mail on a UIAlertView but I dont know how to do this the friend list is obtained from an xml file on my site, and then is parsed an showed on a table with a custom cell design

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

this is the code that creates each cell

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

这篇关于Xcode在UITableRowSelection之后显示UIAlertView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆