Iphone 保持右按钮的可见性?
朋友们好,我在Iphone 保持右按钮的可见性?,iphone,uinavigationbar,Iphone,Uinavigationbar,朋友们好,我在rootViewController中的Navigationbar上添加了UIImageView和UIBarButtonItem。单击BarButten按钮,它将推送第二个viewController。到目前为止,一切正常,但当我在rootViewController中弹出辅助viewControllerUIBarButton时,它就不可见了。谁能告诉我怎么解决这个问题吗 nav = [[UINavigationController alloc] init]; UIImageVie
rootViewController
中的Navigationbar
上添加了UIImageView
和UIBarButtonItem
。单击BarButten
按钮,它将推送第二个viewController。到目前为止,一切正常,但当我在rootViewController
中弹出辅助viewControllerUIBarButton
时,它就不可见了。谁能告诉我怎么解决这个问题吗
nav = [[UINavigationController alloc] init];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, nav.navigationBar.frame.size.width, nav.navigationBar.frame.size.height)];
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
UIImage *navImage = [UIImage imageNamed:@"NavBar-iPad.png"];
imageView.image = navImage;
}
else
{
UIImage *navImage = [UIImage imageNamed:@"NavBar-iPhone.png"];
imageView.image = navImage;
}
[nav.navigationBar addSubview:imageView];
[imageView release];
[nav pushViewController:viewController animated:YES];
我认为您正在尝试向UInavigationBar添加自定义背景 它消失的原因是每个UIViewController都有自己的一组按钮/标题显示在导航栏上。因此,当您按下一个新视图时,它会自动隐藏下面视图的按钮/标题 如果希望按钮看起来相同,则必须在新的UIViewController中重新创建它们 如果您确实需要这些按钮,而不是像现在这样按下新的视图控制器, 您可以这样做:
UINavigationController * navcontrol = [[UINavigationController alloc] initWithRootViewController: viewcontroller];
[navcontrol setNavigationBarHidden: YES];
[self.navigationController pushViewController: navcontrol animated:YES];
[navcontrol release];
[viewcontroller release];
不,只有你能解决这个问题。但是,如果您发布了相关的代码片段,那么这里可能有人可以帮助您。将代码放入视图将显示在RootViewControllerServiceWwillappear中没有帮助。@Hiren443我认为有点混乱。我不想在新的viewController中使用该按钮。我希望当我从第二个ViewController返回rootViewController时,BarButton应该像按下第二个ViewController之前一样可见。谢谢你的回复。