你可以做的一件事是在方法viewWillAppear:
方法中添加圖像,並在viewWillDisappear:
方法中將其從導航欄中刪除。相關代碼塊如下。
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UINavigationBar *bar = [self.navigationController navigationBar];
UIImageView *barImg=[[UIImageView alloc]initWithFrame:CGRectMake(2, 3, 49, 39)];
barImg.image=[UIImage imageNamed:@"smalllogo.png"];
barImg.tag = 100;
[bar addSubview:barImg];
[barImg release];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
UINavigationBar *bar = [self.navigationController navigationBar];
[[bar viewWithTag:100] removeFromSuperview];
}
或者這是另一個簡單的解決方案。下方添加代碼段viewWillAppear:
方法
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"smalllogo.png"]]];
[self.navigationItem setLeftBarButtonItem:item];
[item release];
你需要圖像消失的第二個屏幕? – Dinesh
是的。我不想在我的第二屏幕 –