簡體   English   中英

是否可以在按鈕上啟動scrollView平移手勢

[英]Is it possible to start scrollView pan gesture on a button

我有一個像這樣的層次結構

- UIView 
   - UITableView
   - UIButton

默認情況下,從UIButton滑動不會滾動滾動視圖。 我想改變它,所以它確實如此。

我可以通過將UIButton更改為UILabel並向其添加UITapGestureRecogniser來有效地創建自定義按鈕。

有沒有辦法保持它作為UIButton?

在此輸入圖像描述

-(void)moveUpView
  {  
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:n inSection:0];
    [self.tableView scrollToRowAtIndexPath:indexPath      atScrollPosition:UITableViewScrollPositionTop
                                animated:YES];
        }


希望這可行

創建一個重復的UITableView (具有相同的dataSourcedelegate ),但不要將其插入到視圖層次結構中的任何位置; 只需將其panGestureRecognizer添加到UIButton 實現其委托-scrollViewDidScroll:方法,將原始UITableViewcontentOffset設置為重復的UITableView

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM