【问题标题】:Navigation bar has wrong position when modal a view controller with flip horizontal transition in iOS 7在 iOS 7 中模式化具有翻转水平过渡的视图控制器时,导航栏的位置错误
【发布时间】:2013-10-02 12:29:00
【问题描述】:

当我尝试在 iOS7 中使用翻转水平过渡模态视图控制器时,导航栏的起点是 (0, 0),然后跳转到 (0, 20) 的正确位置。是否有可能使它与 iOS6 中的行为相同?您可以下载项目here

我已经创建了一个自定义导航栏,如下所示:

@implementation MyCustomNavigationBar

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    UIImage *image = [UIImage imageNamed:@"Custom-Nav-Bar-BG.png"];


    [image drawInRect:CGRectMake(0,  0, self.frame.size.width, self.frame.size.height)];

    if (IOSVersion <7) {
    }else{
        self.translucent = NO;
        self.tintColor = [UIColor whiteColor];
        self.barStyle = UIBarStyleDefault;
        self.barTintColor = [UIColor redColor];

    }
}

@end

我们将不胜感激。

【问题讨论】:

  • 嗨,你解决了上面提到的问题吗?
  • 你能告诉我如何解决 iOS 7 中的 filp 过渡吗?
  • @suvi 请检查答案:)

标签: cocoa-touch ios7 uinavigationbar


【解决方案1】:

我和你有同样的问题。我认为这是 iOS 7 上 UIKit 的一个错误。

我在演示文稿的 viewWillAppear 方法中添加了一些代码

     [self.navigationController.navigationBar.layer removeAllAnimations];

当我关闭此视图时,我补充说:

-(IBAction)btnDonePressed:(id)sender {
    [UIView transitionWithView:self.navigationController.view
                      duration:0.75
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:nil
                    completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
}

这对我有用。希望对您有所帮助。

【讨论】:

  • 这也适用于通过翻转动画呈现模态UINavigationController 的segue。我在上面添加了UIView 转换和UIViewAnimationOptionTransitionFlipFromRight 选项到prepareForSegue,它解决了我与这个错误有关的其余问题。我将为此提交一个带有示例项目的雷达。
  • 完美运行.. 谢谢
  • 完美。不过需要注意的是,第一个修复(在 viewWillAppear 上)是为了防止在显示的模态视图上出现凹凸,第二个修复是为了防止返回原始视图时出现凹凸。
  • 在第二次修复中,为了返回原始视图,您可能需要测试设备方向以避免动画冲突。例如。 if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))...
  • @NicolasMiari,苹果似乎解决了这个问题。我在 iOS 9 上没有问题。关于你的问题,我猜苹果在检测后附加了一些动画来改变呈现视图的框架。有关 iOS 7 上导航栏的更多信息,您可以阅读此blog.jaredsinclair.com/post/61507315630/…。我没有更清洁的解决方案,这个答案只是我的解决方案。对不起。
【解决方案2】:

除了破解[navigationBar.layer removeAllAnimations];,这样的东西也应该可以工作:

[UIView transitionWithView:self.view.window duration:FlipDuration options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
    [UIView performWithoutAnimation:^{
        [self presentViewController:modalController animated:NO completion:nil];
    }];
} completion:nil];

【讨论】:

  • 解决了这个问题,恕我直言比接受的答案更好
【解决方案3】:

【讨论】:

  • 我尝试设置导航栏的“ios 6/7 Deltas”,但没有帮助。你也试过了吗?
  • 这些答案给了我一些启示,我已经解决了这个问题,但未能解决问题。
  • 我看到了你的演示,但它的工作正常是值:- self.frame.size.height :44.000000 version==7 rect.size.height :44.000000 self.frame.size.height :44.000000测试[430:a0b] 版本==7 rect.size.height :44.000000
  • 帧值是正确的,但是过渡很奇怪,与iOS6不同。
  • 你能留下你的电子邮件吗?然后我可以将过渡的录制视频发送给您。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-18
  • 1970-01-01
  • 2013-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多