iphone – setNavigationBarHidden:在removeFromSuperview之后没有工作

iphone – setNavigationBarHidden:在removeFromSuperview之后没有工作,第1张

概述我在我的Detail View Controller顶部添加了一个UIWebView子视图,它有一个导航栏.我想在WebView子视图中隐藏导航栏,并在从superview中删除时再次显示它,以便在查看WebView时有更多的屏幕空间. 我的代码的问题是添加子视图后导航栏被成功隐藏,但是当删除子视图时尝试再次显示导航栏时它不起作用. 任何帮助将非常感激.谢谢. 这是我的代码: // In Inst 我在我的Detail VIEw Controller顶部添加了一个UIWebVIEw子视图,它有一个导航栏.我想在WebVIEw子视图中隐藏导航栏,并在从supervIEw中删除时再次显示它,以便在查看WebVIEw时有更多的屏幕空间.

我的代码的问题是添加子视图后导航栏被成功隐藏,但是当删除子视图时尝试再次显示导航栏时它不起作用.

任何帮助将非常感激.谢谢.

这是我的代码:

// 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之后没有工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1004112.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存