【问题标题】:UITableView setContentInset large value animates slowlyUITableView setContentInset 大值动画慢
【发布时间】:2013-07-23 00:08:21
【问题描述】:

我有一个带有另一个视图(称为bottomView)的表视图作为放置在表视图内容底部的子视图。我想要发生的是,当用户在表格视图的最底部拉起时,在释放时我想向上滑动表格视图以便出现bottomView。为此,我实现了委托:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate {
    [UIView animateWithDuration:0.1 animations:^{
        [self.tableView setContentInset:UIEdgeInsetsMake(0, 0, 250, 0)];
    }];
}

(250 是底部视图的高度)在动画块中。我期望发生的是表格视图向上滑动 250pts,显示bottomView。奇怪的是,最终发生的事情是表格只滑了一点点(可能是 100 点)并且滑得很慢,大约 5 秒,而我的动画块只有 0.1 秒。

有人知道为什么会这样吗?

谢谢

【问题讨论】:

    标签: iphone ios cocoa-touch uitableview uiscrollview


    【解决方案1】:

    试试这个,希望对你有帮助


      -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
       {
            aTableView.contentInset = UIEdgeInsetsMake(0, 0, 250, 0);
       }
       -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
       {
            UIEdgeInsets insects =  aTableView.contentInset;
            if(insects.top == 0)
             {
                aTableView.contentInset = UIEdgeInsetsMake(0, 0, 250, 0);
                CGSize size = aTableView.contentSize;
                int height = size.height;
                 [UIView animateWithDuration:0.2 animations:^{
                     aTableView.contentOffset = CGPointMake(0, height-250);
                 }];
                 aTableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
             }
    
       }
    
      -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
      {
          if(!decelerate)
           {
              UIEdgeInsets insects =  aTableView.contentInset;
             if(insects.top == 0)
             {
               CGSize size = aTableView.contentSize;
               int height = size.height;
                  [UIView animateWithDuration:0.1 animations:^{
               aTableView.contentOffset = CGPointMake(0, height-250);
                  }];
               aTableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
             }
          }
      }
    


    根据需要调整contentOffset

    【讨论】:

    • 感谢您抽出宝贵时间回答我的问题。不幸的是,这对我的 tableview 没有明显影响。
    • 你是否将bottomView添加到表格页脚视图中
    • 我根据您在用户向上或向下滚动后提到的内容进行了修改,您希望始终显示该底部视图仪式。我对此进行了检查,我在表格页脚视图中添加了一个高度为 250 像素的视图,当用户向上滚动时它会完美滚动。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-04
    相关资源
    最近更新 更多