设为首页 加入收藏

TOP

App间相互跳转及图片分享(二)
2019-08-31 01:04:54 】 浏览:88
Tags:App 相互 图片 分享
(NSString *)pasteboardType;)

    可以避免全局被使用(需要typeName);

    

    传字典:需要归档

    NSDictionary *dic = @{@"name":@"哈哈碉堡啦",@"image":[UIImage imageNamed:@"qq"]};

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];

    NSData *dictData = [NSKeyedArchiver archivedDataWithRootObject:dic];

    [pasteboard setData:dictData forPasteboardType:@"AType"];

    

    接收:

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];

    NSDictionary *dict = [NSKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForPasteboardType:@"AType"]];

    NSString *name = [dict objectForKey:@"name"];

    */

 

 

 

- (void)backToApp {

    // 1.拿到对应应用程序的URL Scheme

    NSArray *arr = [self.urlString componentsSeparatedByString:@"?"];

    NSString *urlSchemeString = arr[1];

    NSString *urlString = [urlSchemeString stringByAppendingString:@"://"];

    

    // 2.获取对应应用程序的URL

    NSURL *url = [NSURL URLWithString:urlString];

    

    // 3.判断是否可以打开

    if ([[UIApplication sharedApplication] canOpenURL:url]) {

        [[UIApplication sharedApplication] openURL:url];

    }

}

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS之禁止所有输入法的表情 下一篇《看书总结》

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目