[英]UIView is a child of UIScrollview, but when I zoom in or out the UIView doesn't stay in the correct location relative to the image in the scrollview
[英]When I change of UIView my NavigationBar doesn't
我在一個NavigationController中嵌入了一個ViewController,它自定義了NavigationBar(更改代碼中的背景圖像),並且當我單擊按鈕時,它會將用戶正確引導到另一個視圖。 但是,到達此視圖時,我無法更改NavBar的圖像...我試圖這樣寫:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"otherBackground.png"] forBarMetrics:UIBarMetricsDefault];
在IBAction方法中,在主ViewController的ViewDidUnload中,在其他ViewController的ViewDidLoad和initWithNibName中,但沒有任何更改。 我能做什么 ?
我的IBAction如下:
- (IBAction) versModeEmploi : (id) sender
{
if(!modeEmploi) modeEmploi = [[ModeEmploiController alloc] initWithNibName:@"ModeEmploiController" bundle:nil];
UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Retour" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backBarButtonItem;
[self.navigationController pushViewController:modeEmploi animated:NO];
}
非常感謝您的任何建議
非常愚蠢的問題(又稱“您是否嘗試將其關閉然后再次打開?”):
您如何從“嵌入式視圖”過渡到第二個視圖? 它看起來應該像這樣:
[self.navigationController pushViewController:detailViewController animated:YES];
如果沒有,那么self.navigationController
不會在您的第二個視圖中指向任何有用的東西。
此致克里斯
在您的第一個視圖控制器中嘗試以下操作:
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
好吧,如果有人對解決方案感興趣,我只需要使用它來解決問題:
[self.navigationController.navigationBar setNeedsDisplay];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav.png"] forBarMetrics:UIBarMetricsDefault];
這是根據需要添加viewDidAppear / Disappear方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.