Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 旋转前显示/隐藏控件_Iphone_Objective C_Cocoa Touch_Ipad_User Interface - Fatal编程技术网

Iphone 旋转前显示/隐藏控件

Iphone 旋转前显示/隐藏控件,iphone,objective-c,cocoa-touch,ipad,user-interface,Iphone,Objective C,Cocoa Touch,Ipad,User Interface,我有一个使用UISplitViewController的布局,每个窗格底部都有一些自定义控件。当我将视图旋转到纵向模式时,我想在主视图处于popover模式时隐藏主视图控件。这部分很好用 代码如下: - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willRotateToInt

我有一个使用UISplitViewController的布局,每个窗格底部都有一些自定义控件。当我将视图旋转到纵向模式时,我想在主视图处于popover模式时隐藏主视图控件。这部分很好用

代码如下:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
            _refreshButton.hidden = NO;
            _aboutButton.hidden = NO;
            _bottomBar.hidden = NO;
        }
        if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
            _refreshButton.hidden = YES;
            _aboutButton.hidden = YES;
            _bottomBar.hidden = YES;
        }
    }   
}

问题是当我旋转回横向模式时。控件将重新出现,但仅在旋转完成后才显示。它很实用,但很难看。有没有办法强迫他们在旋转实际发生之前重新绘制?

根据我对苹果内置动画的经验,他们会在执行时阻止任何其他正在发生的事情。当你想显示一个预加载程序,同时你对你的界面做了一些非常神奇的事情时,这种情况尤其会发生。方法是在不同的线程上进行自己的GUI管理:

[self performSelectorInBackground:@selector(showHideMenu) withObject:nil];
或者,如果可能的话,删除动画任务,直到你想做什么

[self showHideMenu];
[self performSelector:@selector(doRotation) withObject:nil afterDelay:1];

只是暗中试探一下,但你是否尝试过将调用移动到隐藏/显示代码下方的超级实现?@Till:好主意,但没有骰子。第一个选项(我研究了如何操作)的效果是,控件在旋转到纵向视图之前消失,在旋转回横向视图之后重新出现。我真的不想尝试自己做视图旋转,所以我给了第二个选项一个通行证。我现在所做的是固定控件与视图顶部的距离,并使popover足够短,使它们不会显示在纵向视图中。在代码方面不是很优雅,但从用户的角度来看,它看起来更好。