2012-03-30 35 views
0

這是我迄今爲止。我試圖做的是有一個頂部的滾動條上帶有按鈕,帶你到不同的頁面。我在這裏添加了這個UIScrollView和按鈕,但我無法讓它顯示在屏幕上。我想要頂部滾動爲500像素(以適應其他按鈕),我希望我有那裏的按鈕在啓動時在屏幕中間。我認爲我的問題與我已經提出的座標有關,但我現在已經改變了他們幾個小時,我仍然無法得到它。我的UIScrollView不工作

// init top Scroller 
UIScrollView *topScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(-90,0, 60, 500)]; 
topScroll.contentSize = CGSizeMake(60,500); 
topScroll.showsHorizontalScrollIndicator = YES; 
[self.view addSubview:topScroll]; 
[topScroll setScrollEnabled:YES]; 

//add current games button 
UIButton *currentGamesButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
currentGamesButton.frame = CGRectMake (227, 0,55,55); 
[currentGamesButton addTarget:self 
         action:@selector(goToCurrentGamesViewController:) 
      forControlEvents:UIControlEventTouchUpInside]; 
[currentGamesButton setTitle:@"Current Games" forState:UIControlStateNormal]; 

[topScroll addSubview:currentGamesButton]; 
+1

如果您的滾動視圖寬度爲60px,位於視圖左側-90px,我想這就是爲什麼你沒有看到它。 – SuperRod 2012-03-30 04:30:10

+0

aha ...得到了按鈕顯示=)謝謝...我混合了寬度和高度...謝謝 – nfoggia 2012-03-30 04:33:04

+0

它上下滾動...我怎麼改變它,讓它滾動左右? – nfoggia 2012-03-30 04:33:54

回答

0

這個問題的答案:正如SuperRod在3月30日所說的那樣,我的按鈕的位置在屏幕之外。很抱歉沒有問題,我打算在我把它放在網站上之前仔細檢查我的代碼。

相關問題