簡體   English   中英

如何旋轉UIView?

[英]How do I rotate a UIView?

我完成了本教程: http : //dblog.com.au/iphone-development/iphone-sdk-tutorial-build-your-very-own-web-browser/

現在我想添加一個旋轉窗口的功能,但是我找不到能幫助我的解決方案...

希望有人可以在這里為我提供幫助...我正在尋找幾個小時,找到了一些代碼,但是它們都無法為我工作..也許我做錯了...如果有人可以告訴我將代碼放在哪里,那會很好哪個文件(請看教程)

非常感謝你

在本教程中,導師在主窗口中使用Web視圖,因此在應用程序委托中,我們沒有shouldAutorotateToInterfaceOrientation函數。 您需要做的是創建一個新的窗口基礎項目,並在新項目中添加UIViewController類型的新類。 在這個新類中,從IB添加一個Web視圖,然后在您的應用程序委托中導入新類,將其初始化為

例如,您的新類名稱是FirstViewController,然后在應用程序委托中

 #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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM