標籤:
3DTouch
UITouch類裡API的變化iOS9中添加的屬性
altitudeAngle
當筆平行於平面時,該值為0
當筆垂直於平面時,該值為Pi / 2
estimatedProperties
當前觸摸對象估計的觸摸特性
傳回值是UITouchPropertyies
updatedProperties
當前觸摸對象已經更新的觸摸特性
傳回值是UITouchPropertyies
estimationUpdateIndex
iOS9中添加的方法
- PrecisePreviousLocationInView:
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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
註冊方法聲明在UIViewController類內
[self registerForPreviewingWithDelegate:self sourceView:self.view];
轉載地址:http://www.jianshu.com/p/74fe6cbc542b
iOS 3D touch