2
我现在正在开发支持iOS 4.3和5.0的应用程序。导航栏问题iphone 4.3
我的代码可以正常工作5.0,但会导致4.3中的棘手问题。
问题是:
我有一个视图,其中有一个tableView。该视图具有导航栏,其中包含左侧和右侧导航栏项目。一旦我选择表格视图中的行(并到达相应的视图)并返回,左侧和右侧的导航栏项目“消失”。
过去几个小时我一直在这个烂摊子上,有人得到了治疗?
这是我已经做了:
这是实用的方法,我称之为视负载时。
+ (void)setNavigationBarContents:(UIViewController *)view
{
UIImage *topBarimage=[UIImage imageNamed:NAVIGATION_BAR_IMAGE];
if([view.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
[view.navigationController.navigationBar setBackgroundImage:topBarimage forBarMetrics:UIBarMetricsDefault];
}
else
{
[view.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:topBarimage] aboveSubview:view.navigationController.navigationBar];
}
UIImage *logo=[UIImage imageNamed:LOGO];
UIImageView *logoView=[[UIImageView alloc]initWithImage:logo];
view.navigationItem.titleView = logoView;
UIImage *settingsButtonImage= [UIImage imageNamed:NAVIGATION_SETTINGS];
UIButton *rightBarButton = [UIButton buttonWithType: UIButtonTypeCustom];
[rightBarButton setBackgroundImage: settingsButtonImage forState:UIControlStateNormal];
[rightBarButton addTarget: view action:@selector(settingsButton:) forControlEvents:UIControlEventTouchUpInside];
rightBarButton.frame = CGRectMake(0, 0, 50, 40);
view.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: rightBarButton];
UIImage *logoutButtonImage= [UIImage imageNamed:LOGOUT];
UIButton *leftBarButton = [UIButton buttonWithType: UIButtonTypeCustom];
[leftBarButton setBackgroundImage: logoutButtonImage forState:UIControlStateNormal];
[leftBarButton addTarget: view action:@selector(logout:) forControlEvents:UIControlEventTouchUpInside];
leftBarButton.frame = CGRectMake(0, 0, 65, 32);
view.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: leftBarButton];
}
已经尝试在viewDidLoad和viewWillAppear中调用这个,但徒劳无功。
这就是我在viewController中调用它的方法。
- (void)viewDidLoad
{
[super viewDidLoad];
//other setups here.
[Utility setNavigationBarContents:self];
}
尝试在viewWillAppear中这段代码[实用setNavigationBarContents:自我]。 – Splendid 2012-02-22 07:10:33
我已经尝试过了,正如我之前所说的。感谢您的快速回复 – Guru 2012-02-22 07:14:47
只有酒吧按钮项消失或导航栏消失? – Splendid 2012-02-22 10:55:41