2012-06-19 93 views
0

我在tableview的頂部創建了UIView,其中會有一個imageview,最重要的是會有幾個按鈕。當點擊更改按鈕(導航欄)時,將顯示此UiView。我已經編程添加了一切。但我不能夠利用鈕中存在的UIView無法點擊UIButton iphone

-(IBAction)changeViewController:(id)sender { 
    if(!isViewShowing){ 
     NSLog(@"show Imageview"); 
     viewContainer = [[UIView alloc] initWithFrame: CGRectMake (276, 2, 40, 230)]; 
     UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 230)]; 
     [imageView setImage:[UIImage imageNamed:@"bar.png"]]; 
     UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
     [button addTarget:self action:@selector(buttonPressedAction:)forControlEvents:UIControlEventTouchUpInside]; 
     //[button setTitle:@"Show View" forState:UIControlStateNormal]; 
     button.frame = CGRectMake(0.0, 25.0, 36.0, 36.0); 
     [button setBackgroundImage:[UIImage imageNamed:@"OLFB icon.png"] forState:UIControlStateNormal]; 

     [imageView addSubview:button]; 
     //[imageView release]; 
     [viewContainer addSubview: imageView]; 

     [self.view addSubview:viewContainer]; 
     [self.view bringSubviewToFront:button]; 
     //[polygonView release]; 
     isViewShowing=YES; 
    } 
    else 
    { 
     NSLog(@"view not showing"); 
     [viewContainer removeFromSuperview]; 
     isViewShowing=NO; 
    } 

} 

回答

3

userInteractionEnabledUIImageView的屬性設置爲NO默認..只是讓imageView.userInteractionEnabled = YES;,它會工作。

+0

感謝,它的工作 – user1288005

0

天啊。您可以將imageView的userInteractionEnabled設置爲YES,然後添加到imageView中的按鈕將響應click事件。

imageView.userInteractionEnabled = YES; 
+0

thanks..it工作 – user1288005