Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView底部部件不可单击_Ios_Objective C_Uiview_Uibutton - Fatal编程技术网

Ios UIView底部部件不可单击

Ios UIView底部部件不可单击,ios,objective-c,uiview,uibutton,Ios,Objective C,Uiview,Uibutton,在过去的几天里,我遇到了一个让我发疯的奇怪问题。尝试了论坛上建议的各种事情和技巧,但迄今为止运气不佳。基本上,我有一个tabbarview控制器,当用户点击表格行进入详细信息屏幕时,它带有一个tableview。我在屏幕底部有四个固定按钮,但这些按钮不可点击或无法识别触摸。我想这与主屏幕大小或applicationview框架有关。如果我把按钮放在大约CGRectMake(0330320,50)的位置,这意味着在底部留出大约50个空间,那么它们就可以工作了。以下是此问题的相关代码- //Bott

在过去的几天里,我遇到了一个让我发疯的奇怪问题。尝试了论坛上建议的各种事情和技巧,但迄今为止运气不佳。基本上,我有一个tabbarview控制器,当用户点击表格行进入详细信息屏幕时,它带有一个tableview。我在屏幕底部有四个固定按钮,但这些按钮不可点击或无法识别触摸。我想这与主屏幕大小或applicationview框架有关。如果我把按钮放在大约CGRectMake(0330320,50)的位置,这意味着在底部留出大约50个空间,那么它们就可以工作了。以下是此问题的相关代码-

//Bottom fixed Bar and Buttons//
self.edgesForExtendedLayout=UIRectEdgeNone;

UIImageView *lineImg=[[UIImageView alloc]init];
//lineImg.frame=CGRectMake(0, 748, 320, 2);
[lineImg setBackgroundColor:[UIColor colorWithRed:0.9058 green:0.4705 blue:0 alpha:1.0]];
[self.view addSubview:lineImg];

  addFavBtn=[UIButton buttonWithType:UIButtonTypeCustom];
[addFavBtn setBackgroundColor:[UIColor colorWithRed:0.0392 green:0.1686 blue:0.2196 alpha:1.0]];
[addFavBtn setTitle:@"Add Fav" forState:UIControlStateNormal];
[addFavBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
addFavBtn.titleLabel.textAlignment=NSTextAlignmentCenter;
addFavBtn.titleLabel.font=[UIFont fontWithName:@"MyriadPro-Regular" size:20];
[addFavBtn addTarget:self action:@selector(addFavBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addFavBtn];
addFavBtn.userInteractionEnabled=YES;



UIImageView *lineImg1=[[UIImageView alloc]init];
//lineImg1.frame=CGRectMake(80, 750, 1, 35);
[lineImg1 setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:lineImg1];

shareBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//shareBtn.frame=CGRectMake(81, 750, 79, 35);
[shareBtn setBackgroundColor:[UIColor colorWithRed:0.0392 green:0.1686 blue:0.2196 alpha:1.0]];
[shareBtn setTitle:@"Share" forState:UIControlStateNormal];
[shareBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
shareBtn.titleLabel.textAlignment=NSTextAlignmentCenter;
shareBtn.titleLabel.font=[UIFont fontWithName:@"MyriadPro-Regular" size:20];
[shareBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:shareBtn];

UIImageView *lineImg2=[[UIImageView alloc]init];
//lineImg2.frame=CGRectMake(160, 748, 1, 35);
[lineImg2 setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:lineImg2];


reviewBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//reviewBtn.frame=CGRectMake(161, 750, 79, 35);
[reviewBtn setBackgroundColor:[UIColor colorWithRed:0.0392 green:0.1686 blue:0.2196 alpha:1.0]];
[reviewBtn setTitle:@"Review" forState:UIControlStateNormal];
[reviewBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
reviewBtn.titleLabel.textAlignment=NSTextAlignmentCenter;
reviewBtn.titleLabel.font=[UIFont fontWithName:@"MyriadPro-Regular" size:20];
[reviewBtn addTarget:self action:@selector(reviewBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:reviewBtn];

UIImageView *lineImg3=[[UIImageView alloc]init];
// lineImg3.frame=CGRectMake(240, 750, 1, 35);
[lineImg3 setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:lineImg3];

helpBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//helpBtn.frame=CGRectMake(241, 750, 79, 35);
[helpBtn setBackgroundColor:[UIColor colorWithRed:0.0392 green:0.1686 blue:0.2196 alpha:1.0]];
[helpBtn setTitle:@"Help" forState:UIControlStateNormal];
[helpBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
helpBtn.titleLabel.textAlignment=NSTextAlignmentCenter;
helpBtn.titleLabel.font=[UIFont fontWithName:@"MyriadPro-Regular" size:20];
[helpBtn addTarget:self action:@selector(helpViewBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:helpBtn];

UIImageView *lineImgLast=[[UIImageView alloc]init];
//lineImgLast.frame=CGRectMake(0, 748, 320, 2);
[lineImgLast setBackgroundColor:[UIColor colorWithRed:0.0392 green:0.1686 blue:0.2196 alpha:1.0]];
[self.view addSubview:lineImgLast];



imageNameDetailArray=[[NSMutableArray alloc]init];
parkListDetailArray=[[NSMutableArray alloc]init];
parkListViseDetailArray=[[NSMutableArray alloc]init];

self.responseData=[NSMutableData data];


//get the size of the screen
CGSize result = [[UIScreen mainScreen] bounds].size; //to see the actual screen size - returns 568
CGSize frame = [[UIScreen mainScreen] applicationFrame].size; //to see the application frame size - returns 548
 //UIScreen *screen = [UIScreen mainScreen];
//CGRect fullScreenRect = screen.bounds;

[self.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight];

NSLog(@"mainscreen size - %f",result.height);
NSLog(@"Application frame size - %f",frame.height);

int newSize=cs+50;
int fBar=result.height-50;

homeBg.frame=CGRectMake(0,0, 320, result.height);

//set the height of the scroller view
parkViewScrollView.frame=CGRectMake(0, 63, 320, result.height-128);
parkViewScrollView.contentSize=CGSizeMake(320, newSize);


lineImg.frame=CGRectMake(0, fBar, 320, 2);
addFavBtn.frame=CGRectMake(0, fBar+2, 79, 48);
lineImg1.frame=CGRectMake(80, fBar+2, 1, 48);
shareBtn.frame=CGRectMake(81, fBar+2, 79, 48);
lineImg2.frame=CGRectMake(160, fBar+2, 1, 48);
reviewBtn.frame=CGRectMake(161, fBar+2, 79, 48);
lineImg3.frame=CGRectMake(240, fBar+2, 1, 48);
helpBtn.frame=CGRectMake(241, fBar+2, 79, 48);

谢谢大家的回复。有趣的是,尽管选项卡栏被隐藏了,但我仍然无法使用保留的按钮空间。在推送details视图控制器之前,我使用了以下行。这似乎是工作良好,我现在可以点击所有按钮

//this one line of code did the trick after spending hours of time 
objDetailView.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:objDetailView动画:是]

您在链接图像中显示的按钮是否覆盖了选项卡栏控制器的选项卡?如果是这样的话,你是如何让他们不在标签后面的?你有没有试过把你的按钮视图放在主视图的前面?谢谢你的回复,我试过了,但没有成功。detailview中没有选项卡栏视图-
code
[self.view带来的子视图:addFavBtn];[self.view将子视图带到前台:shareBtn];[self.view将子视图带到前面:reviewBtn];[self.view将子视图带到前台:helpBtn]
code
实际上我意识到我正在使用self.tabBarController.tabBar.hidden=YES隐藏tabbarview;但我仍然不能使用底部的选项卡区域。您是否将按钮放置在scrollview中?如果是这样,请尝试直接将按钮添加到scrollview,而不是向视图中添加按钮,因为这可能与视图大小和scrollview内容大小有关。顺便问一下,您使用的是哪一个xcode版本,您是否在ios 7中对此进行了检查?如果您使用的是自动布局,请尝试将其关闭。