【发布时间】:2016-09-07 00:39:39
【问题描述】:
我有一个带有原型单元格的表格视图。
我的 viewDidLoad 方法中有以下代码,
_refreshControl = [[UIRefreshControl alloc]init];
[_refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
UITableViewController *tableViewController = [[UITableViewController alloc] init];
tableViewController.tableView = _tblView;
tableViewController.refreshControl = _refreshControl;
以下是我的 refreshData 方法....
-(void)refreshData
{
[_request getApproveStatutoryMapping];
UITableViewController *tableViewController = [[UITableViewController alloc] init];
tableViewController.tableView = _tblView;
[_tblView reloadData];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMM d, h:mm a"];
NSString *title = [NSString stringWithFormat:@"Last update: %@", [formatter stringFromDate:[NSDate date]]];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:[UIColor whiteColor]
forKey:NSForegroundColorAttributeName];
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attrsDictionary];
tableViewController.refreshControl.attributedTitle = attributedTitle;
[tableViewController.refreshControl endRefreshing];
}
问题是
- attributedTitle 不可见
- 拉动刷新只能工作一次,如果我再次拉动它,它就不起作用。为什么会这样?
【问题讨论】:
标签: ios objective-c uitableview pull-to-refresh uirefreshcontrol