我有同样的问题,我从上面的答案中得到了一些想法来解决它,但不仅如果我想在表视图滚动时刷新应用程序崩溃,而且它也cr如果我在刷新时滚动,就会灰飞烟灭。因此,解决所有情况下的问题的扩展解决方案是:
1.1。如果用户按下刷新按钮,则禁用滚动功能
1.2。刷新过程完成后启用滚动功能
2.1。如果用户正在滚动,请禁用刷新按钮
2.2。使刷新按钮一旦用户完成滚动
为了实现第一部分(1.1和1.2。):
-(void)startReloading:(id)sender
{
...
self.tableView.userInteractionEnabled = NO;
// and the rest of the method implementation
}
-(void)stopReloading:(id)sender
{
self.tableView.userInteractionEnabled = YES;
// and the rest of the method implementation
}
为了实现第二部分(2.1和2.2。 ):
- (void)scrollViewWillBeginDragging:(UIScrollView *)activeScrollView
{
barButton.enabled = NO;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
barButton.enabled = YES;
}
而且因为它是在以前的答案解释,UISCrollViewDelegate
需要在.h
文件中设置:
@interface MyTableViewController : UITableViewController <UIScrollViewDelegate>
P.S.您可以使用scrollEnabled
而不是userInteractionEnabled
,但这一切取决于您在做什么,但userInteraction是首选选项。
谢谢,我明白了。理由添加到 @interface MyTableViewController:UIViewController 然后实现-scrollViewWillBeginDragging: 谢谢。 –
Rod
2010-02-09 07:51:43
如何才能从特定的表中滚动?举例来说,我有2个UITableViews? – 2014-04-24 06:01:04
@jeraldo,所有UIScrollViewDelegate方法都接受将其作为参数调用的滚动视图,因此您可以轻松确定要处理的是哪个UIScrollView – Vladimir 2014-04-24 06:57:30