2016-01-29 67 views
1

我有一個帶有矩形框架的scrollView來顯示一組子視圖並將它們分頁,我期望其他的子視圖被隱藏,只顯示當前的內容,但是我將所有這些重疊到我的屏幕上。UIScrollView不隱藏內容

enter image description here

if scrollViewHasBeenSetUp == false { 
      var index = 0 
      for event in eventList.events { 
       let match = getMatchCell(event) 
       match.frame = CGRect(x: index * Int(matchScrollView.frame.width), y: 0, width: Int(matchScrollView.frame.width), height: Int(matchScrollView.frame.height)) 
       matchScrollView.contentSize = CGSize(width: Int(match.frame.width) * eventList.events.count, height: 120) 
       matchScrollView.addSubview(match) 
       index++ 
       print("cell frame: \(match.frame)") 
      } 
      scrollViewHasBeenSetUp = true 
     } 

使用視覺檢查就可以看到scrollViews框架已正確設置,但其內容仍沒有被隱藏。

enter image description here

回答

2

你爲什麼選擇剪輯子視圖?

enter image description here

我看到你的y是始終爲0,它是一個垂直滾動的看法?

+0

謝謝,我原以爲這可能是一個默認設置! – Md1079