2014年8月13日 星期三

IOS 偵測裝置旋轉


網路上找了很多方法,但要不是太舊在新的ios6.7已經不能用,就是沒反應。
記錄一下,還可以用的方法。

測試環境:ios7

//畫面旋轉之前,自動調整
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { }

目前為了要相容 iOS 5 和 6 的旋轉,在原本的旋轉方法下,還要加入以下方法。

viewController.mm
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//僅支援直式
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(NSUInteger)supportedInterfaceOrientations
{
//僅支援直式
return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate
{
return YES;
}


以為解決了,結果在 AppDelegate.m 下用

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootviewcontroller = navigationController;

這下可好,完成不理之前的設定(僅支援直式),變成任意旋轉了@_@|||
查了查才發現 self.viewController 是 UIViewController,而被加入 UINavigationController ,旋轉設定並無法影響,解決方法有兩種:
1. 改 UIViewController 為 UINavigationController 的子類別
2. 直接在 AppDelegate.m 覆寫 supportedInterfaceOrientations 方法,如下所示:

@implementation UINavigationController (iOS6OrientationFix)

-(NSUInteger) supportedInterfaceOrientations
{
//被加入的 viewController 為最上層,故只取 topViewController
return [self.topViewController supportedInterfaceOrientations];
}

@end

參考來源:
http://stackoverflow.com/questions/12410031/ios-6-rotations-supportedinterfaceorientations-doesnt-work
http://stackoverflow.com/questions/12504464/ios-6-uitabbarcontroller-supported-orientation-with-current-uinavigation-control


好了,打完收工!


2012年4月25日 星期三

FlashBuilder4.5快速鍵

最近開始用mac來寫flash,
以前被flashdevelop慣壞了,
在mac目前還沒有超好用的fd
所以只好用flashBuilder,
快速鍵的部分找了好久,
我發現用的人不多,網路上的文章也少,
只好自已來找,沒想到讓我找到了,
先記下來 免得以後忘記了,畢竟這功能,
也只會改一次,之後要等到重灌才會在用,
其實快鍵鍵的設定是可以自訂的,
只要從"偏好設定"→General→key 就可以看到全部預設的快速鍵了







另外先把一些常用的記下來,慢慢增加中…


+ Shift + T //檢視專案中的類別原始碼(這個太讚了!!我喜歡!)
 + O //檢視檔案 Outline
option + / //程式碼屬性提示
 + Shift + Space //程式碼參數提示
 + option + R //Rename功能(自動更新專案所有檔案中被更名的成員)
 + option + ↑ //複製游標所在行並貼上在新行
 + option + ↓ //複製游標所在行
 + D //刪除游標所在行
 + Shift + p //尋找成對大括弧
 + E //快速找到已開過的文件
 + 滑鼠左鍵 // 快速跳到變數或function位置

option + ↑ //游標所在行向上移動
option + ↓ //游標所在行向下移動
 + K //尋找(游標反白的字串)
F3 //尋找宣告(如在call function的地方按, 可以跳到該function)
 + / //註解單行
 + Shift + c //註解區塊 /**/ or <!--><-->
’ + Shift + d  //標籤<![CDATA[ ]]>
 + M //編輯視窗放到最大
option + ← //切換到左頁籤檔案
option + → //切換到右頁籤檔案

F11 //Debug
 + F11 //Run
 + B //Build All Projects