Iphone-如何在切换呼叫状态栏时调整视图大小? [英] Iphone- How to resize view when call status bar is toggled?

查看:180
本文介绍了Iphone-如何在切换呼叫状态栏时调整视图大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个在控制器内部包含少量元素的iphone应用程序(例如标签栏,uiview,uitoolbar等)。一切正常,直到我遇到这个问题。当我的应用程序启动时,我接到一个电话,它显示了呼叫状态栏,它破坏了ui。一些元素被推下来,因为呼叫状态栏占据了顶部空间。

I'm creating an iphone app with few elements inside the controller (e.g tab bar, uiview, uitoolbar, etc..). Everything works fine until I encountered this problem. While my application is launched, I received a call and it shows the "Call Status Bar" which ruined the ui. Some elements are pushed down because the "Call Status Bar" is taking space at the top.

这里有人知道如何解决这个问题吗?我是iPhone应用程序开发的新手。

Anybody here have an idea on how to fix this issue? I'm new to iPhone app development.

非常感谢您的回复...

Your reply is greatly appreciated...

最好的问候,

推荐答案

你应该把这个功能放在appDelegate上,这会在状态栏改变时触发

You should put this function on appDelegate, this will trigger when the status bar change

- (void)application:(UIApplication *)application didChangeStatusBarFrame (CGRect)oldStatusBarFrame 
{
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setObject:@"trigger" forKey:@"frame"];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"trigger" object:self userInfo:dict];
}

此代码将发送名称为trigger的通知

This Code will send Notification with the name "trigger"

将代码放入视图控制器(例如:viewDidLoad等)。如果有通知发送名称为触发器,则监听

Place a code to your view Controller (e.g: viewDidLoad, etc..) this listen if there are notification send with a name "trigger"

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(dataReceived:)
                                             name:@"trigger"
                                           object:nil];

并创建一个函数dataReceived:

And create a function dataReceived:

- (void)dataReceivedNotification:(NSNotification *)notification {
    NSDictionary *data = [notification userInfo];
    // do something with data
}

在这部分做点什么代码,也许您更改标签栏,uiview框架,工具栏框架的框架

do something on this part of the code, maybe you change the frame of your tab bar, uiview frame, toolbar frame

并在 dealloc 中,将此代码移除观察者

And in dealloc, put this code to remove the observer

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

这篇关于Iphone-如何在切换呼叫状态栏时调整视图大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆