【问题标题】:XCode In Call Status bar changing the viewXCode 在呼叫状态栏中更改视图
【发布时间】: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


    【解决方案1】:

    使用自动布局,确保设置了Bottom Space 约束:

    【讨论】:

      猜你喜欢
      • 2019-01-19
      • 1970-01-01
      • 2022-01-16
      • 2013-09-09
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多