哪里创建免费的网站优化网站关键词的技巧
在好多APP中,首页中心是几个列表,然而每次从其他界面回到主页,都最好自动刷新一下列表,那么问题来了,如何自动刷新呢?一,可以在ViewWillAppear中调用刷新数据方法;二,用Block或者代理方法调用刷新数据;三,添加通知。
如我的APP是抽屉式框架,中心页是三四个列表。我用的是通知方法。当然这种方法同样适用其他框架,如常用的标签式框架等。
举例说明:A界面点击按钮后,通知B界面去请求网络,刷新B页面的内容 。
解决方案:
1.在B界面创建的时候,如ViewDidLoad里,添加通知:
//回到首页刷新界面通知[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateIndex:) name:@"updateTransferIndex" object:nil];
2.在B界面添加通知调用刷新数据方法:
//MARK:收到通知刷新首页
- (void)updateIndex:(NSNotification *)notification
{[self loadRequest];[self.robbingTable loadRequest:shaixuanMark:(double)self.location.coordinate.latitude:(double)self.location.coordinate.longitude];[self.robbingTable.mainTableView reloadData];[self.sen