gpt4 book ai didi

ios - 在导航项中隐藏返回文本

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:44:38 26 4
gpt4 key购买 nike

我需要通过替换导航栏中的后退文本(按钮)来设置后退箭头。我可以查看后退箭头,但我不知道如何隐藏导航项中的后退文本。这是我的代码:

收到警告:CGImageCreateWithImageProvider:图像大小无效:0 x 0。

(void)viewWillAppear:(BOOL)animated
{
UIImage *backButtonHomeImage = [[UIImage imageNamed:@"back-arrow.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 104, 13)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonHomeImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

self.navigationItem.leftBarButtonItem = nil;
}

最佳答案

答案

    -(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if([self.navigationController.viewControllers objectAtIndex:0] != self)
{
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 26, 26)];
[backButton setImage:[UIImage imageNamed:@"back-arrow.png"] forState:UIControlStateNormal];
[backButton setShowsTouchWhenHighlighted:TRUE];
[backButton addTarget:self action:@selector(popViewControllerWithAnimation) forControlEvents:UIControlEventTouchDown];
UIBarButtonItem *barBackItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.hidesBackButton = TRUE;
self.navigationItem.leftBarButtonItem = barBackItem;
}
}

-(void)popViewControllerWithAnimation
{
[self.navigationController popViewControllerAnimated:YES];

}

可能会有所帮助。

关于ios - 在导航项中隐藏返回文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20216723/

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