Nee*_*esh 0 iphone xcode uitableview uiactivityindicatorview
我的UITableView顶部有一个navigationBar.我在navigationBar右侧有一个刷新按钮.
单击刷新按钮时,我需要启动活动指示器,刷新表并停止活动指示器.
-(void)refreshClicked{
[spinner startAnimating]; //UIActivityIndicatorView object
[appDelegate readJSONData]; //this is the method which populates the array
//for displaying in the tableview
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何在填充数组后刷新表,然后如何停止活动指示器.
谢谢 :)
刷新表:
[tableView reloadData];
Run Code Online (Sandbox Code Playgroud)
停止活动指标:
[spinner stopAnimating];
Run Code Online (Sandbox Code Playgroud)
- - -编辑 - - -
根据你的评论,我可以收集你想要平滑地淡化微调器并重新加载tableview.
对于tableview:
您可以使用以下代码使用漂亮的淡入淡出动画重新加载tableview的各个部分:
[tableView reloadSections:(NSIndexSet *)sections withRowAnimation:UITableViewRowAnimationFade];
Run Code Online (Sandbox Code Playgroud)
您的索引集包含要重新加载的所有部分,并且您还有其他重新加载动画选项.看这里:UITableViewRowAnimations
要创建NSIndexSet,请参阅此链接
至于你的微调器,你可以在调用stopAnimating之前将它淡化为alpha零:
-(void)fadeSpinner
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(stopAnimation)];
spinner.alpha = 0;
[UIView commitAnimations];
}
- (void)stopAnimation
{
[spinner stopAnimating];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3008 次 |
| 最近记录: |