我的代码的问题是添加子视图后导航栏被成功隐藏,但是当删除子视图时尝试再次显示导航栏时它不起作用.
任何帮助将非常感激.谢谢.
这是我的代码:
// In InstrumentsDetailVIEwController.m- (IBAction)edu1link:(ID)sender { _webVIEwController = [[WebVIEwController alloc] initWithNibname:@"WebVIEwController" bundle:nil]; [UIVIEw beginAnimations:@"flipPing vIEw" context:nil]; [UIVIEw setAnimationDuration:1]; [UIVIEw setAnimationCurve:UIVIEwAnimationCurveEaseInOut]; [UIVIEw setAnimationTransition: uiviewanimationtransitionFlipFromleft forVIEw:self.vIEw cache:YES]; [self.vIEw addSubvIEw:_webVIEwController.vIEw]; [self.navigationController setNavigationbarHIDden:YES animated:YES]; [UIVIEw commitAnimations];}// In WebVIEwController.m- (IBAction) donebutton:(ID)sender { [UIVIEw beginAnimations:@"flipPing vIEw" context:nil]; [UIVIEw setAnimationDuration:1]; [UIVIEw setAnimationCurve:UIVIEwAnimationCurveEaseInOut]; [UIVIEw setAnimationTransition: uiviewanimationtransitionFlipFromright forVIEw:self.vIEw.supervIEw cache:YES]; [self.vIEw removeFromSupervIEw]; [self.navigationController setNavigationbarHIDden:NO animated:YES]; [UIVIEw commitAnimations];}解决方法 对于我在代码中看到的内容:
– 您正在向InstrumentDetailVIEwController实例主视图添加子视图.
– 子视图是WebVIEwController实例的主视图.
但是…… WebVIEwController永远不会被推送或d出到您的导航堆栈.因此,您的WebVIEwController实例没有对navigationController的引用,并且调用[self.navigationController]会将您的setNavigationbarHIDden:NO animated:YES消息发送给… nil
您可以:
– 将WebvIEwController实例推送/d出到导航堆栈,因此它将引用navigationController.
要么
– 将您的WebVIEwController实例添加为InstrumentsDetailVIEwController的CHILD,然后调用
[[[self parentVIEwController] navigationController] setNavigationbarHIDden:NO animated:YES];
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
搜索addChildVIEwController:
总结以上是内存溢出为你收集整理的iphone – setNavigationBarHidden:在removeFromSuperview之后没有工作全部内容,希望文章能够帮你解决iphone – setNavigationBarHidden:在removeFromSuperview之后没有工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)