应用程序生命周期问题

编程入门 行业动态 更新时间:2024-10-28 18:27:14
本文介绍了应用程序生命周期问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经更改了导航栏,这意味着我增加了导航栏的高度&进行了一些自定义更改,效果很好,但是当我最小化应用程序并再次最大化它时,它仅显示原始高度,这是我所做的更改,最小化后这些无效,我的代码是

i have made changes in navigation bar means i have increasd the height of navigation bar & made some custom changes,it works fine but when i minimizes the application and again maximize it, it shows only original height that is what changes i made, those not works after minimization, my code is

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSLog(@" i m in didFinishLaunchingWithOptions" ); [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"TopHeader"] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setFrame:CGRectMake(0, 0, 320, 55)]; [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:(-15.0) forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], UITextAttributeTextColor, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:16.0], UITextAttributeFont, nil]]; return YES; }

最大化后进入applicationDidBecomeActive,这就是为什么我在applicationDidBecomeActive中放置了上面的代码,但是却无法正常工作,为什么会这样? 最小化之前 最小化后再次最大化,如下所示,即高度再次自动设置为44.

after maximize it goes to applicationDidBecomeActive thats why i put above code in applicationDidBecomeActive but its not working, why this is happening? before minimize after minimize & maximize again it looks like below i.e. height again automatically sets to 44.

更新:我在applicationWillEnterForeground

- (void)applicationWillEnterForeground:(UIApplication *)application { UINavigationController *my=(UINavigationController * )self.window.rootViewController; UINavigationBar *navigationBar = [my navigationBar]; CGRect frame = [navigationBar frame]; frame.size.height = 55.0f; [navigationBar setFrame:frame]; NSLog(@" i m in applicationWillEnterForeground" ); }

在调试时,当我写它的描述时,它显示高度为55.但是在屏幕上,它仍然看起来像第二张图像.为什么会这样.

at the time of debugging when i writes its description it shows that height is 55. but on screen it still looks like second image. why this is happening.

推荐答案

我解决了这个问题,只是覆盖了UINavigationBar&在LayoutSubViews中设置导航栏的高度.

I solved this problem, just overrides the UINavigationBar & in LayoutSubViews set the height of navigationBar.

@implementation UINavigationBar (customNAvigBar) - (void)layoutSubviews { [self setFrame:CGRectMake(0, 0, 320, 55)]; } @end

这意味着每当我绘制navigationBar时,它都会自动调用&设置高度.

that means whenever i draws the navigationBar it calls automatically & sets the height.

更多推荐

应用程序生命周期问题

本文发布于:2023-11-17 04:16:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608796.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   生命周期

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!