你好,游客 登录 注册 搜索
背景:
阅读新闻

iOS学习之Table View的简单使用

[日期:2012-06-14] 来源:csdn  作者:totogo2010 [字体:大 中 小]
10、设置行的风格
表示UITableViewCell风格的常量有:

UITableViewCellStyleDefault
UITableViewCellStyleSubtle
UITableViewCellStyleValue1
UITableViewCellStyleValue2
可以自己修改看看效果。可以添加一个detail

 cell.detailTextLabel.text =@"打打打打";

return cell; 





11、选择table里的某一行

在.m文件@end之前编写  -(void)table  这时会自动提示可以实现的方法,


我们选择这个方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

选中是做个提示,提示选中了那个信息,代码实现如下:

  1. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  
  2.     NSString *rowString = [self.list objectAtIndex:[indexPath row]];  
  3.     UIAlertView * alter = [[UIAlertView alloc] initWithTitle:@"选中的行信息" message:rowString delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];  
  4.     [alter show];  
  5. }  
效果:

以上是Plain风格的TableView

例子代码:

 

10、设置行的风格
表示UITableViewCell风格的常量有:

UITableViewCellStyleDefault
UITableViewCellStyleSubtle
UITableViewCellStyleValue1
UITableViewCellStyleValue2
可以自己修改看看效果。可以添加一个detail

 cell.detailTextLabel.text =@"打打打打";

return cell; 





11、选择table里的某一行

在.m文件@end之前编写  -(void)table  这时会自动提示可以实现的方法,


我们选择这个方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

选中是做个提示,提示选中了那个信息,代码实现如下:

  1. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  
  2.     NSString *rowString = [self.list objectAtIndex:[indexPath row]];  
  3.     UIAlertView * alter = [[UIAlertView alloc] initWithTitle:@"选中的行信息" message:rowString delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];  
  4.     [alter show];  
  5. }  

效果:

以上是Plain风格的TableView

例子代码:

 

10、设置行的风格
表示UITableViewCell风格的常量有:

UITableViewCellStyleDefault
UITableViewCellStyleSubtle
UITableViewCellStyleValue1
UITableViewCellStyleValue2
可以自己修改看看效果。可以添加一个detail

 cell.detailTextLabel.text =@"打打打打";

return cell; 





11、选择table里的某一行

在.m文件@end之前编写  -(void)table  这时会自动提示可以实现的方法,


我们选择这个方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

选中是做个提示,提示选中了那个信息,代码实现如下:

  1. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  
  2.     NSString *rowString = [self.list objectAtIndex:[indexPath row]];  
  3.     UIAlertView * alter = [[UIAlertView alloc] initWithTitle:@"选中的行信息" message:rowString delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];  
  4.     [alter show];  
  5. }  

效果:

以上是Plain风格的TableView

例子代码:

 

10、设置行的风格
表示UITableViewCell风格的常量有:

UITableViewCellStyleDefault
UITableViewCellStyleSubtle
UITableViewCellStyleValue1
UITableViewCellStyleValue2
可以自己修改看看效果。可以添加一个detail

 cell.detailTextLabel.text =@"打打打打";

return cell; 





11、选择table里的某一行

在.m文件@end之前编写  -(void)table  这时会自动提示可以实现的方法,


我们选择这个方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

选中是做个提示,提示选中了那个信息,代码实现如下:

  1. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  
  2.     NSString *rowString = [self.list objectAtIndex:[indexPath row]];  
  3.     UIAlertView * alter = [[UIAlertView alloc] initWithTitle:@"选中的行信息" message:rowString delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];  
  4.     [alter show];  
  5. }  

效果:

以上是Plain风格的TableView

例子代码:

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2012年资料/6月/14日/iOS学习之Table View的简单使用/

linux
相关资讯       iOS编程开发 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款