学习iOS技术iOS开发经验总结iOS开发收集

[iOS]iOS9 3DTouch、ShortcutItem、P

2015-09-10  本文已影响18931人  肖浩呗

3DTouch


UITouch类里API的变化

iOS9中添加的属性

altitudeAngle

estimatedProperties

updatedProperties

estimationUpdateIndex

iOS9中添加的方法

- PreciseLocationInView:

- PrecisePreviousLocationInView:

- azimuthAngleInview:

- azimuthUnitVectorInView:

UIForceTouchCapability

UIForceTouchCapabilityUnknown

UITouchType

UITouchTypeDirect

UITouchProperties

UITouchPropertyForce


ShortcutItem


静态方式

动态方式

修改当前应用程序的某个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
创建一个新的Item图标

当程序启动时


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];
上一篇 下一篇

猜你喜欢

热点阅读