iOS9 3DTouch、ShortcutItem、Peek And Pop技術一覽

來源:互聯網
上載者:User

標籤:

[iOS]iOS9 3DTouch、ShortcutItem、Peek And Pop技術一覽 3DTouchUITouch類裡API的變化iOS9中添加的屬性

altitudeAngle

  • 當筆平行於平面時,該值為0

  • 當筆垂直於平面時,該值為Pi / 2

estimatedProperties

  • 當前觸摸對象估計的觸摸特性

  • 傳回值是UITouchPropertyies

updatedProperties

  • 當前觸摸對象已經更新的觸摸特性

  • 傳回值是UITouchPropertyies

estimationUpdateIndex

  • 當每個觸摸對象的觸摸特性發生變化時,該值將會單獨增加

  • 傳回值是NSNumber

iOS9中添加的方法

- PreciseLocationInView:

  • 當前觸摸對象的座標

- PrecisePreviousLocationInView:

  • 當前觸摸對象的前置座標

- azimuthAngleInview:

  • 沿著x軸正向的方位角

  • 當與x軸正向方向相同時,該值為0

  • 當view參數為nil時,預設為keyWindow

- azimuthUnitVectorInView:

  • 當前觸摸對象的方向上的單位向量

  • 當view參數為nil時,預設為keyWindow

UIForceTouchCapability

UIForceTouchCapabilityUnknown

  • 不能確定是否支援壓力感應
    UIForceTouchCapabilityUnavailable
  • 不能支援壓力感應
    UIForceTouchCapabilityAvailable
  • 可以支援壓力感應
UITouchType

UITouchTypeDirect

  • 垂直的觸摸類型
    UITouchTypeIndirect
  • 非初值的觸摸類型
    UITouchTypeStylus
  • 水平的觸摸類型
UITouchProperties

UITouchPropertyForce

ShortcutItem靜態方式
  • 開啟Info.plist檔案
  • 在對應UIApplicationShortcutItems關鍵字下添加item
動態方式修改當前應用程式的某個shortcutItem
  //擷取第0個shortcutItem    id oldItem = [existingShortcutItems objectAtIndex: 0];    //將舊的shortcutItem改變為可修改類型shortcutItem    id mutableItem = [oldItem mutableCopy];    //修改shortcutItem的顯示標題    [mutableItem setLocalizedTitle: @“Click Lewis”];
擷取當前應用程式的shortcutItems
  //擷取當前應用程式物件    UIApplication *app = [UIApplication sharedApplication];    //擷取一個應用程式物件的shortcutItem列表    id existingShortcutItems = [app shortcutItems];
重設當前應用程式的shortcutItems
  //根據舊的shortcutItems產生可變shortcutItems數組    id updatedShortcutItems = [existingShortcutItems mutableCopy];    //修改可變shortcutItems數組中對應index下的元素為新的shortcutItem    [updatedShortcutItems replaceObjectAtIndex: 0 withObject: mutableItem];    //修改應用程式物件的shortcutItems為新的數組    [app setShortcutItems: updatedShortcutItems];
建立一個新的UIApplicationShortcutItem
  • 初始化函數

    • - initWithType:localizedTitle:localizedSubtitle:icon:userInfo:
    • - initWithType:localizedTitle:
  • 屬性

    • localizedTitle:NSString

    • - localizedSubtitle:NSString

    • - type:NSString

    • - icon:UIApplicationShortcutIcon

    • - userInfo:NSDictionary

    • 只有唯讀特性,想要進行修改時,需要通過mutableCopy方法轉變為
      NSMutableApplicationShortcutItem
建立一個新的Item表徵圖
  • 初始化函數

    • + iconWithType:

    • + iconWithTemplateImageName:

    • + iconWithContact:

當程式啟動時
  • 判斷launchOptions字典內的UIApplicationLaunchOptionsShortcutItemKey是否為空白
  • 當不為空白時,application:didFinishLaunchWithOptions方法返回false,否則返回true
  • 在application:performActionForShortcutItem:completionHandler方法內處理點擊事件
Peek and Pop註冊預覽功能的代理對象和源視圖代理對象需要接受UIViewControllerPreviewingDelegate協議
  @interface RootVC<UIViewControllerPreviewingDelegate>    {}    @end
代理對象實現協議內的Peek和Pop方法
  @implementation RootVC    - (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)context viewControllerForLocation:(CGPoint) point    {        UIViewController *childVC = [[UIViewController alloc] init];        childVC.preferredContentSize = CGSizeMake(0.0f,300f);        CGRect rect = CGRectMake(10, point.y - 10, self.view.frame.size.width - 20,20);        context.sourceRect = rect;        return childVC;    }    - (void)previewContext:(id<UIViewControllerPreviewing>)context commitViewController:(UIViewController*)vc    {        [self showViewController:vc sender:self];    }    @end
註冊方法聲明在UIViewController類內
[self registerForPreviewingWithDelegate:self sourceView:self.view];

iOS9 3DTouch、ShortcutItem、Peek And Pop技術一覽

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.