顯示具有 iOS 6 標籤的文章。 顯示所有文章
顯示具有 iOS 6 標籤的文章。 顯示所有文章

2012年10月1日 星期一

旋轉,就是那麼簡單 ~ 全新iOS 6旋轉機制

在 iOS 6之前,想要控制App畫面的旋轉,採用的是以下method

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

此method雖然簡單,但我們還是需要依據參數toInterfaceOrientation來做判斷,依據是否支援此方向而回傳YES或NO,例如以下例子:


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait)
    {
        return YES;
    }
    else
    {
        return NO;
    }
}
說明:
只鍾情於一種角度,iPhone為直立方向,且home按鈕在下方(UIInterfaceOrientationPortrait)。將iPhone轉至其它方向時,畫面並不會跟著轉動。


   

                                 

在iOS 6更簡單了,改為利用以下method定義App支援的方向。

- (NSUInteger)supportedInterfaceOrientations
{
        return UIInterfaceOrientationMaskPortrait;
}

說明:
想要支援哪些方向,直接回傳方向的Mask即可。完整的方向mask定義,可參考UIApplication.h。


typedef NS_OPTIONS(NSUInteger, UIInterfaceOrientationMask) {
    UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
    UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
    UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
    UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
    UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
    UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
    UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
};

讓我們再來看看另一個例子,如果想要全方向的支援,只要回傳UIInterfaceOrientationMaskAll即可。









2012年9月17日 星期一

只要有iPhone,人人都可以是攝影大師 - iOS 6的全景拍照

iOS 6支援全景拍照,而且不只iPhone 5獨享唷,連iPhone 4S也擁有此非凡能力。接下來,就讓彼得潘手上的iPhone 4S,為各位示範拍攝愛車的全景照片吧。不過可惜彼得潘不是有錢的蝙蝠俠布魯斯韋恩,所以拍攝的不是高級跑車,只是小小的單車啦。

1. 打開相機App,點選"選項"按鈕,再選擇"全景模式"


2. 進入傻瓜全景拍照模式。只要持續移動iPhone,即可完成全景照片。



3.  大功告成 ! 只要有iPhone,人人都可以是攝影大師 。