【发布时间】:2015-03-24 12:06:38
【问题描述】:
我在 XCode 中创建了一个 Viewcontroller,一切正常。当有电话来电时,通话状态栏正在按下视图底部的“DOWN”按钮,因为在通话过程中我无法单击该按钮。
我想知道如何将按钮保持在底部,即使来电时也保持相同的位置。我尝试了几种方法都对我不起作用。
- (void)statusBarFrameWillChange:(NSNotification*)notification {
NSValue* rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey];
CGRect newFrame;
[rectValue getValue:&newFrame];
CGRect fixedFrame = bottomBar.frame;
fixedFrame.origin.y = fixedFrame.origin.y - newFrame.size.height; //Keep the Y position as it is
bottomBar.frame = fixedFrame;
NSLog(@"statusBarFrameWillChange: newSize %f, %f, %f", fixedFrame.origin.y, newFrame.size.width, newFrame.size.height);
}
- (void)statusBarFrameChanged:(NSNotification*)notification {
NSValue* rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey];
CGRect oldFrame;
[rectValue getValue:&oldFrame];
CGRect fixedFrame = bottomBar.frame;
fixedFrame.origin.y = fixedFrame.origin.y + oldFrame.size.height;
bottomBar.frame = fixedFrame;
NSLog(@"statusBarFrameChanged: oldSize %f, %f, %f", fixedFrame.origin.y, oldFrame.size.width, oldFrame.size.height);
}
【问题讨论】:
标签: ios objective-c xcode uiview uiviewcontroller