【发布时间】:2014-04-09 03:09:24
【问题描述】:
我在我的 tableviewcontroller 中创建了一个 UIRefreshcontrol,如下在 viewdidload 方法中:
refresh = [UIRefreshControl.alloc init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self action:@selector(refreshChatsTableView) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;
问题在于,当我将其拉长一点时,表格会抖动起来,给人一种非常不愉快的 UI 体验。有人可以帮忙吗?此行为仅在横向模式下才会出现。
这是我的代码:
-UIRefreshControl *refresh;
-(void)viewDidLoad{
[super viewDidLoad];
arr= [[NSArray alloc]initWithObjects:@"A",@"B",@"C",@"D",@"E",@"A",@"B",@"C",@"D",@"E", nil];
//refresh control
refresh = [UIRefreshControl.alloc init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self action:@selector(refreshChatsTableView) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;
}
-(void)refreshChatsTableView{
[refresh endRefreshing];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return arr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =[[UITableViewCell alloc]init];
cell.textLabel.text = [arr objectAtIndex:indexPath.row ];
return cell;
}
【问题讨论】:
-
这不正常。也许您正在其他地方调整内容偏移量?
-
不!我不会在任何地方改变它。事实上,我创建了一个新示例,我只是在表格中填充了一个数组并添加了这个控件。你从来没有经历过这个吗?
-
我已经用我的代码更新了帖子
标签: ios objective-c ios7 pull-to-refresh uirefreshcontrol