UITableView数据刷新
案例说明:点击对应的条目,然后弹出对话框,输入文字,可以修改对应条目的内容
如何做到刷新呢? 原理是修改我们的模型,跟listview一样
下面二个方法怎么理解呢?
我们点击其中一行,会触发第一个方法didSelectRowAtIndexPath,当我们点击其他行的时候,前一次被点击的行会触发取消选中方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 选中方法监听器
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 取消选中监听器
重新加载模型数据,刷新
//全部刷新
[self.tabView reloadData];
//局部刷新:
[self.tabView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationRight];
#import "ViewController.h"
#import "FLHero.h"
@interface ViewController () <UITableViewDataSource, UITableViewDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tabView;
@property(nonatomic, strong) NSArray *heros;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tabView.rowHeight = 60;//设置行号高度,这里设置是所有的
}
- (BOOL)prefersStatusBarHidden
{
re
UITableView数据刷新
最新推荐文章于 2021-01-10 22:20:20 发布