美文网首页
3D Touch 的实现

3D Touch 的实现

作者: 呦嚯嚯嚯12138 | 来源:发表于2016-10-03 15:59 被阅读8次

1、在didFinishLaunchingWithOptions:添加以下代码

UIApplicationShortcutItem *shortItem1 = [[UIApplicationShortcutItem alloc] initWithType:@"斋打开" localizedTitle:@"斋打开"];

UIApplicationShortcutItem *shortItem2 = [[UIApplicationShortcutItem alloc] initWithType:@"弹框" localizedTitle:@"弹框"];

NSArray *shortItems = [[NSArray alloc] initWithObjects:shortItem1, shortItem2, nil];

NSLog(@"%@", shortItems);

[[UIApplication sharedApplication] setShortcutItems:shortItems];

2、添加以下代码

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{

if ([shortcutItem.localizedTitle  isEqual: @"弹框"]) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"OPPS!" message:@"我的CTO叫佛山强" delegate:self cancelButtonTitle:@"哦" otherButtonTitles:nil, nil];

[alert show];

return;

}

相关文章

网友评论

      本文标题:3D Touch 的实现

      本文链接:https://www.haomeiwen.com/subject/mfkjyttx.html