我在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;
}
}
感謝,它的工作 – user1288005