【问题标题】:Toolbar and Navigationbar bad Animation工具栏和导航栏不良动画
【发布时间】:2011-08-24 18:02:55
【问题描述】:

我想做的是在横向模式下旋转并将工具栏和导航栏留在(工具栏垂直于右侧,导航栏垂直于左侧),但仅旋转视图和图标在工具栏和导航栏上.. 到目前为止我所做的是使用 willAnimateSecondHalfofRotation。当进入横向模式时,位置是我想要的,但我可以看到旋转的过渡,它看起来很糟糕。我想做的是像 iPhone 的相机一样工具栏的图标正在旋转...

你能帮帮我吗? 先谢谢了。 洛尔

【问题讨论】:

  • 可以添加图片吗?这很难理解。

标签: iphone objective-c ios


【解决方案1】:
  1. 禁用自动旋转:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    
  2. 注册 UIDeviceOrientationDidChange 通知:

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
    
  3. 响应设备方向变化:

    - (void)orientationChanged:(NSNotification *)notification {
        // Adjust views according to [[UIDevice currentDevice] orientation];
    }
    
  4. 别忘了注销

    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    

【讨论】:

    猜你喜欢
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 2020-10-17
    相关资源
    最近更新 更多