标签:
再仔细说下:
1:tableview滑动前,下面悬浮的按钮隐藏
2:tableview被拉动后,下面悬浮的按钮出现,点击这个按钮tableview滚动到顶端。(便于分页加载多页后用户能立即滚动到顶端)
- (void)viewDidLoad
{
aTopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
aTopBtn.frame = CGRectMake(ScreenWidth-50,ScreenHeight-64-105, 35, 35);
aTopBtn.backgroundColor = [UIColor clearColor];
aTopBtn.hidden=YES;
[aTopBtn setImage:[UIImage imageNamed:@"zs_shanghuabiao"] forState:UIControlStateNormal];
[aTopBtn addTarget:self action:@selector(aToping:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:aTopBtn];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"scrollView.contentOffset.y%f",scrollView.contentOffset.y);
if (scrollView.contentOffset.y>0) {
aTopBtn.frame = CGRectMake(ScreenWidth-50,ScreenHeight-64-105, 35, 45);
aTopBtn.hidden=NO;
[aTopBtn setImage:[UIImage imageNamed:@"zs_huitou"] forState:UIControlStateNormal];
} else {
aTopBtn.frame = CGRectMake(ScreenWidth-50,ScreenHeight-64-105, 35, 35);
aTopBtn.hidden=YES;
[aTopBtn setImage:[UIImage imageNamed:@"zs_shanghuabiao"] forState:UIControlStateNormal];
}
}
//回到顶端
-(void)aToping:(UIButton *)sender{
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
}
tableview(scrollview)被拉动后能立即滚动到顶端
标签:
原文地址:http://www.cnblogs.com/huangzs/p/4488799.html