最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS9 系統(tǒng)分享調(diào)用之UIActivityViewController

 更新時(shí)間:2015年11月03日 14:34:04   投稿:mrr  
UIActivityViewController類(lèi)是一個(gè)標(biāo)準(zhǔn)的view controller,通個(gè)使用這個(gè)controller,你的應(yīng)用程序就可以提供各種服務(wù)。本文給大家介紹iOS9 系統(tǒng)分享調(diào)用之UIActivityViewController,感興趣的朋友一起學(xué)習(xí)吧

UIActivityViewController類(lèi)是一個(gè)標(biāo)準(zhǔn)的view controller,通個(gè)使用這個(gè)controller,你的應(yīng)用程序就可以提供各種服務(wù)。

系統(tǒng)提供了一些通用的標(biāo)準(zhǔn)服務(wù),例如拷貝內(nèi)容至粘貼板、發(fā)布一個(gè)公告至社交網(wǎng)、通過(guò)email或者SMS發(fā)送內(nèi)容。

應(yīng)用程序同樣可以自定義服務(wù)。(我的微信分享就屬于自定義服務(wù), 之后將會(huì)寫(xiě)一篇教程介紹)

你的應(yīng)用程序負(fù)責(zé)配置、展現(xiàn)和解雇這個(gè)view controller。

viewcontroller的配置涉及到viewcontroller需要用到的具體的數(shù)據(jù)對(duì)象。(也可以指定自定義服務(wù)列表,讓?xiě)?yīng)用程序支持這些服務(wù))。

在展現(xiàn)view controller時(shí),必須根據(jù)當(dāng)前的設(shè)備類(lèi)型,使用適當(dāng)?shù)姆椒?。在iPad上,必須通過(guò)popover來(lái)展現(xiàn)view controller。在iPhone和iPodtouch上,必須以模態(tài)的方式展現(xiàn)。

昨天有網(wǎng)友說(shuō)我寫(xiě)的那段系統(tǒng)分享代碼在iOS9上有warning,看下了原來(lái)ios8之后UIPopoverController被廢棄了。新增加的UIPopoverPresentationController在控制PopView上更簡(jiǎn)單好用。

這里寫(xiě)圖片描述

下面是我修改之后的代碼:

1. 在app內(nèi)以子視圖方式打開(kāi)其他app預(yù)覽,僅支持6.0以上

openAppWithIdentifier(appId: String)

2. 分享文字圖片信息,ipad上會(huì)以sourceView為焦點(diǎn)彈出選擇視圖

share(textToShare: String, url: String, image: UIImage, sourceView: UIView)
/// 在app內(nèi)以子視圖方式打開(kāi)其他app預(yù)覽,僅支持6.0以上
 private func openAppWithIdentifier(appId: String) {
 if let _ = NSClassFromString("SKStoreProductViewController") {
  let storeProductViewController = SKStoreProductViewController()
  storeProductViewController.delegate = self
  let dict = NSDictionary(object:appId, forKey:SKStoreProductParameterITunesItemIdentifier) as! [String : AnyObject]
  storeProductViewController.loadProductWithParameters(dict, completionBlock: { (result, error) -> Void in
//  self.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)")!)
 }
 }
 /// 分享文字圖片信息,ipad上會(huì)以sourceView為焦點(diǎn)彈出選擇視圖
 private func share(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)
  }
 }
 }

相關(guān)文章

最新評(píng)論

商丘市| 商丘市| 安康市| 荆门市| 工布江达县| 寿阳县| 曲沃县| 蒲江县| 北川| 湾仔区| 镇安县| 万安县| 凤台县| 兴海县| 开化县| 寿光市| 黄梅县| 屏东县| 娄烦县| 梅河口市| 凉山| 香河县| 库车县| 苏尼特右旗| 邵东县| 温宿县| 甘洛县| 五莲县| 津市市| 五峰| 中卫市| 灵台县| 太保市| 当阳市| 锦州市| 赤水市| 监利县| 南和县| 扶余县| 绥阳县| 湖州市|