IOS9 system share call (Uiactivityviewcontroller)

Source: Internet
Author: User

Yesterday, a netizen said that I wrote that part of the system to share code on the iOS9 have warning, see the original iOS8 after Uipopovercontroller was discarded. The newly added uipopoverpresentationcontroller is easier to use on the control Popview.

Here's the code I modified:

1. Open other app previews in the app in sub-view mode, only support more than 6.0

Openappwithidentifier (appid:string)

2. Share the text image information, the ipad will focus on Sourceview to select the view

Share (texttoshare:string, url:string, Image:uiimage, Sourceview:uiview)

Open other app previews within the app in sub-view, only support 6.0 or morePrivate FuncOpenappwithidentifier (appid:string) {IfLet _ = nsclassfromstring ("Skstoreproductviewcontroller") {Let Storeproductviewcontroller = Skstoreproductviewcontroller () Storeproductviewcontroller.delegate = SelfLet Dict = Nsdictionary (Object:appid, Forkey:skstoreproductparameteritunesitemidentifier)as! [String:anyobject] Storeproductviewcontroller.loadproductwithparameters (dict, Completionblock: {(result, error)- > VoidInchSelf.presentviewcontroller (Storeproductviewcontroller, Animated:true, Completion:nil)}) Self.presentviewcontroller (Storeproductviewcontroller, animated:True, Completion:nil)}else {uiapplication.sharedapplication (). OpenURL (Nsurl (String"Itms-apps://itunes.apple.com/app/id\ (APPID)")!) } }Share text picture information, the ipad will focus on Sourceview to select the viewPrivate FuncShare (texttoshare:string, url:string, Image:uiimage, Sourceview:uiview) {Let objectstoshare = [Texttoshare, URL, image] let Activityviewcontroller = Uiactivityviewcontroller ( Activityitems:objectstoshare, Applicationactivities:nil) if Uidevice.currentdevice (). UserInterfaceIdiom = = Uiuserinterfaceidiom.phone {Self.presentviewcontroller (Activityviewcontroller, animated: true, Completion:nil) }else {let popover = Activityviewcontroller.popoverpresentationcontroller if (popover! = nil) {PopOver?. Sourceview = Sourceview popover?. Sourcerect = Sourceview.frame popover?. Permittedarrowdirections = Uipopoverarrowdirection.any Self.presentviewcontroller (activityViewController, animated : True, Completion:nil)        }}}

IOS9 system share call (Uiactivityviewcontroller)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.