2013-06-21 24 views
3

我是新的iphone開發..我在我的應用程序中添加了滾動視圖,並在滾動視圖內添加了10個按鈕圖形。但是當我運行了滾動不滾動滾動視圖不在xib文件滾動

我的代碼如下

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [scrollview setContentSize:CGSizeMake(1500,50)]; 

    [scrollview setBackgroundColor:[UIColor blackColor]]; 
    [self.view addSubview:scrollview]; 
} 
+0

沒有背景色獲得通過您的代碼設置爲黑色,在那裏? –

+0

你是如何將你的課堂與課堂聯繫起來的? – yinkou

+0

你是如何添加按鈕? – Venkat

回答

2

它看起來像你正在滾動視圖在廈門國際銀行。因此,您需要從代碼中刪除[self.view addSubview:scrollview];,並且可以直接在xib中設置該滾動視圖的屬性,但setContentSize(需要在.m文件中設置)除外。

或者,如果你想手動創建滾動視圖,從廈門國際銀行取出,並使用此:

UIScrollView * content = [[UIScrollView alloc] initWithFrame:self.view.bounds]; 
[content setContentSize:CGSizeMake(width, height)]; 
//Here you can add those buttons to content view 
[self.view addSubView:content]; 
+0

也增加了這個滾動視圖的高度。 50太小。 –