gpt4 book ai didi

ios - iOS 7 部分导航返回项不可点击

转载 作者:行者123 更新时间:2023-11-29 02:33:55 25 4
gpt4 key购买 nike

我的导航后退按钮有问题,最上面的按钮不可点击,只有一半(底部)可以点击。

这是它的屏幕截图:

enter image description here

我放了一个边框来知道按钮的大小,但唯一可点击的部分用黄线标记。

我也尝试过手动操作按钮但得到了相同的结果,这是我的代码:

UIImage *buttonImage = [UIImage imageNamed:@"arrow_back.png"];
navButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[navButton setImage:buttonImage forState:UIControlStateNormal];
navButton.layer.borderWidth =1.0f;
[navButton addTarget:self action:@selector(backButton:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem * barItem = [[UIBarButtonItem alloc] initWithCustomView:navButton];
self.navigationController.navigationItem.leftBarButtonItem = barItem;

编辑:

当我删除代码(意味着我使用默认代码)时,可点击部分变为:

enter image description here

编辑:

为了更清楚,这里是父 View Controller 的代码(加载 View )

-(void) loadView{
scroll_flag = 0;
webService = [[WebServiceController alloc] init];
webService.webserviceDelegate = self;

secondTabView = [[SecondTabView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
secondTabView.secondTabViewDelegate = self;
self.view = secondTabView;
isDisplayed = NO;
x=0;

[secondTabView setupLayout];
self.navigationController.delegate = self;
self.edgesForExtendedLayout = UIRectEdgeNone;


dictTrap = [[NSMutableArray alloc] init];
secondTabView.tableView.delegate = self;
secondTabView.tableView.dataSource = self;
mapView.delegate = self;
}

这是我在推送 View Controller 中的代码:

secondTabNextController = [[SecondTabNextViewController alloc] init];
[self.navigationController pushViewController:secondTabNextController animated:YES];

以及包含后退按钮的 Controller 代码

-(void) loadView {
secondTabNextView = [[SeconTabNextView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
secondTabNextView.secondTabNextDelegate = self;
self.view = secondTabNextView;
heartVal = 0;
commentVal = 0;
[secondTabNextView setupLayout];
webService = [[WebServiceController alloc] init];
webService.webserviceDelegate = self;
dateTimeArray = [[NSMutableDictionary alloc] init];

secondTabNextView.contentScrollView.delegate = self;
self.navigationController.delegate = self;
self.pageControl = [[UIPageControl alloc] init] ;
self.pageControl.frame = CGRectMake(110,385,100,20);
self.pageControl.currentPage = 0;
self.pageControl.hidden = YES;
[self.pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.pageControl];
pageControl.pageIndicatorTintColor = [UIColor redColor];
feedsArray = [[NSMutableArray alloc] init];

UIButton * theView = [[UIButton alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, 46)];
[self addViewToTab: loginController.tab :theView];
[theView bringSubviewToFront:self.view];
[self.tabBarController.view addSubview:theView];

btnHeart = [UIButton buttonWithType:UIButtonTypeCustom];
[btnHeart setImage:[UIImage imageNamed:@"heart_gray.png"] forState:UIControlStateNormal];
[self addHeartButton:self.tabBarController :btnHeart];
[self.tabBarController.view addSubview:btnHeart];

btnComment = [UIButton buttonWithType:UIButtonTypeCustom];
[self addCommentButton:self.tabBarController :btnComment];
[self.tabBarController.view addSubview:btnComment];
}

我已经删除了代码并使用默认值。

最佳答案

在此处添加新按钮似乎是一种非常奇怪的方式。我从来没有遇到过这个特殊问题,但我知道你不应该把按钮放在离导航栏底部(下面)太近的地方,因为导航栏会“拦截”触摸,所以当你添加时这可能是一个类似的问题一个 UIButton 作为 subview 。

无论如何,UINavigationItem 有一个 leftBarButtonItem 属性,为什么不使用它呢?

这样的事情怎么样:

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"arrow_back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backButton:)];

关于ios - iOS 7 部分导航返回项不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26582725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com