簡體   English   中英

如何從第一個View控制器中出現的第二個UIView Controller中刪除UINavigationBar label.text?

[英]How to remove UINavigationBar label.text from second UIView Controller which is coming in first View controller?

我有一個標簽,它使用addSubView屬性顯示在UINavigationBar上,並且顯示如下: 在此處輸入圖片說明

但是,當我要使用secondView Controller時,它看起來像: 在此處輸入圖片說明

它出現在第二個控制器的后退按鈕上。 因此,如何從第二個UI中刪除“狀態”標簽。

謝謝。

不要將子視圖添加到導航欄中。 不是為了這個。 我建議您閱讀iOS人機界面指南,並使用UIBarButtonItem將控件正確添加到導航欄中。

您應該標記您的子視圖並在第二個視圖控制器的導航欄子視圖中搜索它,然后在[subview removeFromSuperview]

您不應該將子視圖添加到導航欄中,可以使用導航項來實現這種功能。 您可以使用initWithCustomView:初始化一個UIBarButtonItem ,其中帶有該標簽。

在第一個View控制器中-

-(void)viewWillAppear:(BOOL)animated 
{
    //Add Label on UINavigationBar
      [super viewWillAppear:animated];
      [self.navigationController.navigationBar addSubview:navLabel];
}

-(void)viewWillDisappear:(BOOL)animated 
{
    // Remove label from UINavigationBar
    [super viewWillDisappear:animated];
    [navLabel removeFromSuperview];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM