2013-12-23 82 views
0

我有一個UIScrollView類的子類,這個滾動有垂直內容。但我需要在水平方向上將此UIScrollView拖放到父視圖中。我怎樣才能實現這個?在你做什麼,你必須去你StoryBored和取消FileInspector下的自動佈局選項水平拖動的UIScrollView

+0

是什麼在滾動視圖?自定義視圖還是內置視圖?如果是後者,他們是'UIControl'嗎? – Tommy

+0

UIscrollView有少量子視圖垂直對齊。 –

+0

iOS本身不會拖動 - 但如果它們是'UIControl',那麼添加它比僅僅是'UIView'要容易得多。那麼他們是自定義的還是內置的?如果它們是內置的,它們是否控制了子類? – Tommy

回答

0

你必須有一個特定的層次。

  • 查看
    • 滾動型
      • ContainerView(如果你想要一個或有一個)
        • 查看
        • UIControl(如果有的話)
        • 您的視圖的內容。

然而,你必須使滾動視圖的聲明在你的頭文件:

IBOutlet UIScrollView *yourScrollViewName; 

在你的主viewDidLoad中下:

-(void)viewDidLoad { 
yourScrollViewName.translatesAutoresizingMaskIntoConstraints = NO; 
[yourScrollViewName setScrollEnabled:YES]; 
[yourScrollViewName setContentSize:CGSizeMake(320 ,554)]; //320 is the x which is the width. change this to make it horizontal. 
//554 is the Height this has to be larger that the screen size in order to have vertical scrolling. 
[yourScrollViewName setPagingEnabled:NO]; 
}