我有一個UIScrollView。在這個UIScrollView裏面是一個包含所有其他子視圖(包括UIButton)的UIView。它與UIScrollView具有相同的邊界。UIButton沒有響應當放在它的容器UIScrollView
我想:
- 的的UIScrollView的底部不滾動能(其中UIButton的放置)。
- UIButton是響應式的。
所以我設置的UIScrollView比的UIView如下圖像高一點的底部:
這將使的UIButton沒有反應(這是響應左側佈局)。任何建議?謝謝!
我的代碼一些部分:
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero];
[self addSubview:self.scrollView];
self.scrollContent = [[UIView alloc] initWithFrame:CGRectZero];
[self.scrollView addSubview:self.scrollContent];
self.button = [UIButton buttonWithType:UIButtonTypeCustom];
[self.scrollContent addSubview:self.button];
[self.button addTarget:self
action:@selector(buttonPressed)
forControlEvents:UIControlEventTouchUpInside];
更新:
貌似正確的方法是保持滾動視圖的底部,並設置其contentSize,但因爲我使用的自動佈局,我發現contentSize的高度始終爲零?
看起來這是行不通的。另一個問題是我有一個按鈕最初放在滾動視圖之外。我滾動後,按鈕也沒有響應... – mlin956