2012-04-22 9 views
0

これは私がこれまでに持っていたことですが、スクロール側とスクロール側にある2つのボタンがありますが、スクロールしないので2番目のボタンになります。私のコードで誰かがこのエラーを見ることができたら大変感謝します。UIScrollViewが適切にスクロールしていない

UIScrollView *mainScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 65, 320, 4000)]; 
mainScroll.contentSize = CGSizeMake(320, 4000); 
mainScroll.showsHorizontalScrollIndicator = YES; 
[self.view addSubview:mainScroll]; 
[mainScroll setScrollEnabled:YES]; 


UIButton *mainCreateGame = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[mainCreateGame addTarget:self 
        action:@selector(goToCreateGameViewController) 
     forControlEvents:UIControlEventTouchUpInside]; 
[mainScroll addSubview:mainCreateGame]; 
mainCreateGame.frame = CGRectMake(75, 10, 170, 60); 



UIButton *anotherButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[anotherButton addTarget:self 
        action:@selector(goFuckOffApple) 
     forControlEvents:UIControlEventTouchUpInside]; 
[mainScroll addSubview: anotherButton]; 
anotherButton.frame = CGRectMake(75, 3000, 170, 60); 

答えて

1

それはコンテンツだとしてまあ、陽気なメソッド名(GOF ** kOffApple、LOL)のほかに、あなたは同じサイズにあなたのスクロールビューの枠を設定しています。フレームとコンテンツのサイズは異なる動物です。これを試してみてください:

UIScrollView *mainScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 65, 320, 395)]; 
mainScroll.contentSize = CGSizeMake(320, 4000); 
mainScroll.showsVerticalScrollIndicator = YES; 
[self.view addSubview:mainScroll]; 
[mainScroll setScrollEnabled:YES]; 


UIButton *mainCreateGame = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[mainCreateGame addTarget:self 
        action:@selector(goToCreateGameViewController) 
     forControlEvents:UIControlEventTouchUpInside]; 
[mainScroll addSubview:mainCreateGame]; 
mainCreateGame.frame = CGRectMake(75, 10, 170, 60); 



UIButton *anotherButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[anotherButton addTarget:self 
        action:@selector(goFuckOffApple) 
     forControlEvents:UIControlEventTouchUpInside]; 
[mainScroll addSubview: anotherButton]; 
anotherButton.frame = CGRectMake(75, 3000, 170, 60); 
+0

lol ...私はその時点でリンゴにちょっと怒っていました。ハハハハはトンの男に感謝します。 =) – nfoggia

+1

問題ありません。私はまだメソッド名を笑っている... – CodaFi

+1

haha​​ha私は彼らが私のアプリの笑を受け入れると思います – nfoggia

関連する問題