簡體   English   中英

滾動視圖的UI按鈕不交互

[英]UIbutton of scrollview not interacting

我的問題是,當我以編程方式將滾動視圖添加到subView時,我的Button和其他所有控件均無法正常工作。

override func viewDidLoad() {
 super.viewDidLoad()
 if(self.appDelegate.screenWidth < 568){
        self.scrollView = UIScrollView(frame: view.bounds)
        self.scrollView.delegate = self
        self.scrollView.contentSize = CGSizeMake(self.appDelegate.screenWidth, 568)
        scrollView.delaysContentTouches = false
        scrollView.canCancelContentTouches = true
        scrollView.scrollEnabled = true
        // mainView consists all other controls like UIButton and other
        scrollView.addSubview(mainView)
        view.addSubview(scrollView)
    }
}


  override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    if(self.appDelegate.screenWidth < 568){
        scrollView.frame = view.bounds
        mainView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height)
    }
}

解決此查詢的任何建議???

提前致謝

我真的相信這與您的視圖層次結構有關。 您正在將滾動視圖添加到所有其他UI控件UIButton等之上。所有UI控件應為滾動視圖的子視圖,以使滾動和控件正常運行。

暫無
暫無

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

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