我在我的UINavigationController标题下添加了一个小标记,以便用户知道标题是可点击的。您可以在下面的代码中看到如何将此标签添加到导航栏中。无法从UINavigationController.view中删除UILabel
_labelCalendarMenuArrow = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/2 - 5, 30, 10, 26)];
_labelCalendarMenuArrow.text = @" ̬";
_labelCalendarMenuArrow.font = [UIFont fontWithName:@"HelveticaNeue" size:30];
_labelCalendarMenuArrow.textAlignment = NSTextAlignmentCenter;
_labelCalendarMenuArrow.textColor = [UIColor whiteColor];
[self.navigationController.view addSubview:_labelCalendarMenuArrow];
问题是我离开此屏幕时无法从navigationController.view中删除此UILabel。在下面的代码中,您可以看到我如何尝试隐藏或删除此UILabel的一些方法,但它们都不工作...... UILabel将保留在NavigationController中,直到我转到不同的视图堆栈并返回。有什么建议?
- (void)viewWillDisappear:(BOOL)animated {
[_labelCalendarMenuArrow removeFromSuperview];
_labelCalendarMenuArrow = nil;
_labelCalendarMenuArrow.alpha = 0;
}
顺便说一句 - 在@“̬”我用我的标签是有点怪异,并显示出了怪异的串...应该是之间引用而不是在右引号之下。 ......或许这与它有关...... – Adama 2015-02-10 17:36:14
刚刚测试......不,这与这个问题无关。 – Adama 2015-02-10 17:38:08