我有一点虫子。我正在开发iOS应用程序。 如果我接到电话,我的应用程序将保持打开状态,我的应用程序屏幕将显示在我的应用程序中。如果我有电话,我想关闭我的应用程序。 我该如何解决这个问题?
谢谢,
学家
答案 0 :(得分:0)
绿色,通话中状态栏不是错误,而是功能。您不需要在通话时关闭应用程序。
相反,请确保在显示通话中状态栏时正确调整视图大小。
答案 1 :(得分:0)
按照Apple人机界面指南
Never quit an iOS app programmatically because people tend to interpret this as a crash.
However, if external circumstances prevent your app from functioning as intended, you need
to tell your users about the situation and explain what they can do about it. Depending on
how severe the app malfunction is, you have two choices.
Display an attractive screen that describes the problem and suggests a correction. A
screen provides feedback that reassures users that there’s nothing wrong with your app. It
puts users in control, letting them decide whether they want to take corrective action and
continue using your app or press the Home button and open a different app
If only some of your app's features are unavailable, display either a screen or an alert
when people use the feature. Display the alert only when people try to access the feature
that isn’t functioning. `
但是,当您使用以下通知
进行通话时,您也会相应地处理您的应用[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incomingCall:) name:CTCallStateIncoming object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:nil];
答案 2 :(得分:0)
Srinivasan N的回答有不正确的观察者,你会想要添加这个会考虑所有场景的观察者:电话,个人热点,GPS /导航等。
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(adjustViews:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
}
- (void)adjustViews:(NSNotification *)notification
{
NSValue *rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey];
CGRect newFrame;
[rectValue getValue:&newFrame];
NSLog(@"Changed frame to: Width: %f, Height: %f", newFrame.size.width, newFrame.size.height);
// Adjust your views here
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}