Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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_Rotation_Uiinterfaceorientation - Fatal编程技术网

iphone:点击按钮将旋转视图

iphone:点击按钮将旋转视图,iphone,rotation,uiinterfaceorientation,Iphone,Rotation,Uiinterfaceorientation,尝试手动旋转视图时出现问题。例如,我有一个在横向运行的视图控制器,在该视图上有一个按钮。我想点击该按钮,强制视图旋转到纵向(倒立纵向)。我搜索了一下,但找不到答案 感谢您的帮助您可以尝试以下方法: - (void)buttonPressed { // check current orientation if ([[UIApplication sharedApplication] statusBarOrientation] != UIDeviceOrientationLandsc

尝试手动旋转视图时出现问题。例如,我有一个在横向运行的视图控制器,在该视图上有一个按钮。我想点击该按钮,强制视图旋转到纵向(倒立纵向)。我搜索了一下,但找不到答案

感谢您的帮助

您可以尝试以下方法:

- (void)buttonPressed {

    // check current orientation
    if ([[UIApplication sharedApplication] statusBarOrientation] != UIDeviceOrientationLandscapeLeft) {

        // no, the orientation is wrong, we must rotate the UI
        self.view.userInteractionEnabled = NO;

        // setup status bar
        [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];
        // rotate main view, in this sample the view of navigation controller is the root view in main window
        [self.view setTransform: CGAffineTransformMakeRotation(M_PI / 2)];
        // set size of view
        [self.view setFrame:CGRectMake(0, 0, 748, 1024)];

    }

}

你能发布你有问题的代码吗?对不起,这只是个想法,我还没有代码。对不起,我回复晚了,你的答案是正确的。非常感谢。:-)如何在通用应用程序(iPhone4/5、iPad/iPad视网膜/iPad迷你版)中找到框架尺寸?