首页 > 其他 > 详细

自定义UITableViewCell上的delete按钮

时间:2014-12-17 20:27:18      阅读:159      评论:0      收藏:0      [点我收藏+]

1.通过UITableViewDelegate方法可以实现删除 tableview中某一行 

//滑动删除

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{   

    NSUInteger row = [indexPath row];

    [bookInforemoveObjectAtIndex:row];//bookInfo为当前table中显示的array

    [tableView deleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationLeft];

}


此 时删除按钮为Delete,如果想显示为“删除” 中文的话,则需要实现UITableViewDelegate中的- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath方

 

[plain] view plaincopy
 
  1. - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{    
  2. }    

或者,最简单的方式,将plist中的Localization native development region改为China即可

 

 

2.这只是让默认的Delete按钮显示成了中文的删除按钮而已,如果想将这个删除按钮换成其他图片形式的,怎么办呢?

[cpp] view plaincopy
 
  1. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath    
  2. static;    
  3. if ] forState:UIControlStateNormal];    
  4. for ifclass return void for if break }    

自定义UITableViewCell上的delete按钮

原文:http://www.cnblogs.com/z-j-w/p/4170055.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!