Iphone 如何旋转UIView?

Iphone 如何旋转UIView?,iphone,objective-c,ios,Iphone,Objective C,Ios,我完成了本教程: 现在我想添加一个旋转窗口的函数,但我找不到一个解决方案来帮助我 希望有人能在这里帮助我。。。我搜索了几个小时,找到了一些代码,但它们对我都不起作用。。也许我做错了什么。。。如果有人能告诉我把代码放在哪个文件里就好了(请看教程) 非常感谢您是否覆盖了方法shouldAutorotateToInterfaceOrientation 控制器的示例代码: // Override to allow orientations other than the default portrait

我完成了本教程:

现在我想添加一个旋转窗口的函数,但我找不到一个解决方案来帮助我

希望有人能在这里帮助我。。。我搜索了几个小时,找到了一些代码,但它们对我都不起作用。。也许我做错了什么。。。如果有人能告诉我把代码放在哪个文件里就好了(请看教程)


非常感谢

您是否覆盖了方法
shouldAutorotateToInterfaceOrientation

控制器的示例代码:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // return (interfaceOrientation == UIInterfaceOrientationPortrait);
    retrun YES; // to support all rotation
}

在本教程中,导师使用的是主窗口中的web视图,因此应用程序内委托我们没有
shouldAutorotateToInterfaceOrientation
功能。您需要做的是创建一个新的窗口基项目,并在新项目中添加UIViewController类型的新类。在这个新类中,从IB添加一个web视图,并在应用程序中委托导入新类,将其初始化为

例如,您的新类名是FirstViewController,然后是in-app delegate.m

 #import "FirstViewController"
然后在ApplicationIDFinishLaunching中

FirstViewController *fvc = [[FirstViewController alloc] init];
[window addSubView:fvc.view];

然后在FirstViewController中,从方法
shouldAutorotateToInterfaceOrientation
中删除注释,因为它已经存在,但刚刚注释过,并且还要确保在
shouldAutorotateToInterfaceOrientation
函数中有
返回YES然后您就可以旋转视图了。

不,我刚刚学习了教程,如何使用它?我是xcode的新手:(教程只能带你到目前为止。你需要在
shouldAutorotateToInterfaceOrientation