xcode – UITabBar按钮问题,TabBar按钮变为无法点击

xcode – UITabBar按钮问题,TabBar按钮变为无法点击,第1张

概述我正在使用UINavigationBar和UITabBar创建一个视图.我在标签栏上添加了一个按钮,点击按钮,我隐藏标签栏并在底部显示工具栏.我的代码是针对当前以及之前的iOS版本编写的.我正在使用此代码self.edgesForExtendedLayout = UIRectEdgeNone;对于iOS7,这是我的代码: - (void)hideTabBar { UITabBar *tab 我正在使用UINavigationbar和UITabbar创建一个视图.我在标签栏上添加了一个按钮,点击按钮,我隐藏标签栏并在底部显示工具栏.我的代码是针对当前以及之前的iOS版本编写的.我正在使用此代码self.edgesForExtendedLayout = UIRectEdgeNone;对于iOS7,这是我的代码:

- (voID)hIDeTabbar {    UITabbar *tabbar = self.tabbarController.tabbar;    UIVIEw *parent = tabbar.supervIEw; // UILayoutContainerVIEw    UIVIEw *content = [parent.subvIEws objectAtIndex:0];  // UITransitionVIEw    UIVIEw *window = parent.supervIEw;enter code here    [UIVIEw animateWithDuration:0.5                     animations:^{                         CGRect tabFrame = tabbar.frame;                         tabFrame.origin.y = CGRectGetMaxY(window.bounds);                         tabbar.frame = tabFrame;//                         CGRect contentFrame = content.frame;//                         contentFrame.size.height -= tabFrame.size.height;                         content.frame = window.bounds;                     }];     if ([[[UIDevice currentDevice] systemVersion] intValue] < 7.0)     {    CGRect frame = tbl_Allfiles.frame;    frame.size.height -=tabbar.frame.size.height;    tbl_Allfiles.frame = frame;     }}- (voID)showTabbar {    UITabbar *tabbar = self.tabbarController.tabbar;    UIVIEw *parent = tabbar.supervIEw; // UILayoutContainerVIEw    UIVIEw *content = [parent.subvIEws objectAtIndex:0];  // UITransitionVIEw    UIVIEw *window = parent.supervIEw;    if ([[[UIDevice currentDevice] systemVersion] intValue] < 7.0)    {    CGRect frame = tbl_Allfiles.frame;    frame.size.height +=tabbar.frame.size.height;    tbl_Allfiles.frame = frame;    }    [UIVIEw animateWithDuration:0.5                     animations:^{                         CGRect tabFrame = tabbar.frame;                         tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabbar.frame);                         tabbar.frame = tabFrame;                         CGRect contentFrame = content.frame;                         contentFrame.size.height -= tabFrame.size.height;                         content.frame = contentFrame;                     }];}- (voID)loadToolbar {    toolbar = [UIToolbar new];    toolbar.barStyle = UIbarStyleBlackTranslucent;        movebutton = [UIbutton buttonWithType:UIbuttonTypeCustom];    [movebutton setFrame:CGRectMake(10,10,120,25)];    [movebutton setBackgroundcolor:[UIcolor redcolor]];    [movebutton setTitle:@"Move" forState:UIControlStatenormal];    [movebutton addTarget:self action:@selector(movefile_Folder:) forControlEvents:UIControlEventtouchUpInsIDe];    UIbarbuttonItem *moveItem = [[[UIbarbuttonItem alloc] initWithCustomVIEw:movebutton] autorelease];    moveItem.style = UIbarbuttonItemStylebordered;    NSArray *items = [NSArray arrayWithObjects:moveItem,nil];    toolbar.items = items;    [toolbar sizetoFit];    CGfloat toolbarHeight = [toolbar frame].size.height;    CGRect mainVIEwBounds = self.vIEw.bounds;    if ([[[UIDevice currentDevice] systemVersion] intValue] < 7.0)    {        [toolbar setFrame:CGRectMake(CGRectGetMinX(mainVIEwBounds),CGRectGetMinY(mainVIEwBounds) + CGRectGetHeight(mainVIEwBounds) - (toolbarHeight),CGRectGetWIDth(mainVIEwBounds),toolbarHeight)];    }    else    {        [toolbar setFrame:CGRectMake(CGRectGetMinX(mainVIEwBounds),CGRectGetMinY(mainVIEwBounds) + CGRectGetHeight(mainVIEwBounds),toolbarHeight)];    }    [self.vIEw addSubvIEw:toolbar];    [toolbar bringSubvIEwToFront:self.vIEw];}

我的问题是按钮单击hIDeTabbar和loadToolbar方法被调用.一切都运行正常,除了我的按钮现在在工具栏上无法点击.@H_404_14@请帮我.

解决方法 如果你的vIEwcontroller不是根视图控制器iOS没有获取视图框,我有一个类似的问题.

在vIEwdIDload中将此行添加到vIEwcontroller,

self.vIEw.frame = [UIScreen mainScreen].bounds;

希望能帮助到你

总结

以上是内存溢出为你收集整理的xcode – UITabBar按钮问题,TabBar按钮变为无法点击全部内容,希望文章能够帮你解决xcode – UITabBar按钮问题,TabBar按钮变为无法点击所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1054289.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存