我完成這個教程: http://dblog.com.au/iphone-development/iphone-sdk-tutorial-build-your-very-own-web-browser/如何旋轉UIView?
,現在我想添加一個功能旋轉窗口,但我不能找到一個解決方案,幫助我......
希望有人能幫助我在這裏...我正在尋找幾個小時,發現了一些代碼,但他們都不會爲我工作..也許我犯了一些錯誤......如果有人能告訴我將代碼放在哪個文件中(請看教程)
非常感謝你
我完成這個教程: http://dblog.com.au/iphone-development/iphone-sdk-tutorial-build-your-very-own-web-browser/如何旋轉UIView?
,現在我想添加一個功能旋轉窗口,但我不能找到一個解決方案,幫助我......
希望有人能幫助我在這裏...我正在尋找幾個小時,發現了一些代碼,但他們都不會爲我工作..也許我犯了一些錯誤......如果有人能告訴我將代碼放在哪個文件中(請看教程)
非常感謝你
在本教程中,導師是使用在主窗口中的Web視圖,所以在應用程序委託我們沒有shouldAutorotateToInterfaceOrientation
功能。你必須做的是創建一個新的基於窗口的項目,並在新的項目中添加新類的UIViewController類型。在這個新的類從IB和你的應用程序代理進口新類添加Web視圖,它初始化爲
例如新的類名是FirstViewController然後在應用delegate.m
#import "FirstViewController"
然後在在applicationDidFinishLaunching
FirstViewController *fvc = [[FirstViewController alloc] init];
[window addSubView:fvc.view];
然後在FirstViewController刪除評論的方法shouldAutorotateToInterfaceOrientation
,因爲它已經存在,但只是評論,也確保在shouldAutorotateToInterfaceOrientation
功能有return YES;
然後你將能夠旋轉一個視圖。
您是否覆蓋方法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
}
不,我只是按照教程,我該如何使用它?我是一個新手在xcode :( – njaknjak 2011-04-26 13:18:58
教程只能帶你到目前爲止。你需要搜索Apple Docs'shouldAutorotateToInterfaceOrientation' – 2011-04-26 13:22:11