2011-06-28 2 views
0

良い一日、仲間のプログラマーには表示されません第三に、その他の連続UIButtonsは、UIScrollViewを

それが今、私はこの問題を解決しようとしましたので、時間となっています。 FacebookのiOSアプリと同じメニュービューを作成する予定です。問題は、私はUIScrollViewに2つまでUIButtonsを追加することができます、3番目と他の連続したボタンが表示されません。あなたが私にこれを手伝ってくれることを願っていますここで

は、コードブロックです:

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
self.navigationController.navigationBarHidden = NO; 
for (int i = 0; i < colors.count; i++) { 
    CGRect frame; 
    frame.origin.x = self.scrollView.frame.size.width * i; 
    frame.origin.y = 0; 
    frame.size = self.scrollView.frame.size; 

    UIView *subview = [[UIView alloc] initWithFrame:frame]; 

    if(i == 0) 
    { 

     UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; //Creates a UIButton 

     button.frame = CGRectMake(25, 65, 70, 70); //sets the coordinates and dimensions of UIButton 

     button.backgroundColor = [UIColor clearColor]; //sets the background color 

     [button addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; //sets the target and action for the button 

     [button setBackgroundImage:[UIImage imageNamed:@"Message Board Icon-57.png"] forState:UIControlStateNormal]; //sets the background Image 


     [subview addSubview:button]; 
     [button release]; 

     UIButton *button2 = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; //Creates a UIButton 

     button2.frame = CGRectMake(125, 175, 70, 70); //sets the coordinates and dimensions of UIButton 

     button2.backgroundColor = [UIColor clearColor]; //sets the background color 

     [button2 addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; //sets the target and action for the button 

     [button2 setBackgroundImage:[UIImage imageNamed:@"Profile Page Icon-57.png"] forState:UIControlStateNormal]; //sets the background Image 

     [subview addSubview:button2]; 
     [button2 release]; 


     UIButton *button3 = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; //Creates a UIButton 

     button3.frame = CGRectMake(125, 65, 70, 70); //sets the coordinates and dimensions of UIButton 

     button3.backgroundColor = [UIColor clearColor]; //sets the background color 

     [button3 addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; //sets the target and action for the button 

     [button3 setBackgroundImage:[UIImage imageNamed:@"iCalendar Icon-57.png"] forState:UIControlStateNormal]; //sets the background Image 


     [subview addSubview:button3]; 
     [button3 release]; 


    } 
    [subview release]; 
} 

self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count, self.scrollView.frame.size.height); 

} 
+0

タイプを丸い矩形に変更すると、ボタンが表示されますか? – dasdom

+0

UIView *サブビューをscrollViewに追加して、それをボタンやボタンに表示する必要があります。ちょうど、[scrollview addsubview:subview]; –

+0

私は今問題を見つけることができました。私のイメージ名にいくつかのタイプミスがあり、これがUIScrollViewに追加された不一致を引き起こしました...私の懸念を読む時間をとってくれた@dasdomと@iphonePlayerに感謝します。 –

答えて

0

あなたはそれもボタンでそれを表示するにはscrollViewにあなたUIView *subviewを追加する必要があります。ちょうど、[scrollView addSubview:subView];

+0

@iphonePlayerの頭に感謝します...私のコードブロックの問題は、論理よりも活字です。 –

関連する問題