IOS X上tabbar横屏后tabbar错乱问题

//@interface LK_TabBarViewController : UITabBarController
//X上横屏后返回tabbar错乱问题,记得释放掉!!!居然忘了remove了。。。闪退了才发现。
[self.tabBar addObserver:self forKeyPath:@"frame" options:(NSKeyValueObservingOptionNew| NSKeyValueObservingOptionOld) context:nil];


-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    NSLog(@"KVO--old=%@---new=%@",change[@"old"],change[@"new"]);
    CGRect oldFrame = [change[@"old"] CGRectValue];
    CGRect newFrame = [change[@"new"] CGRectValue];
    if (oldFrame.size.height!= newFrame.size.height) {
        if (oldFrame.size.height>newFrame.size.height) {
            self.tabBar.frame=oldFrame;
        }else{
            self.tabBar.frame=newFrame;
        }
    }
}

你可能感兴趣的:(IOS X上tabbar横屏后tabbar错乱问题)