【发布时间】:2015-07-13 01:57:38
【问题描述】:
我已按照question 将 1Password 扩展程序包含在我的浏览器应用程序中。
但是,我的应用程序上已经有一个 iOS 8 共享表 (ActivityViewController),并且想在此共享表中包含 1Password 以使用它自己的。我的应用程序在 Swift 中,但 1Password 在 Objective-C 中。
这是我用于 ActivityViewController 的代码:
@IBAction func _shareButton(sender: UIButton) {
var shareContent = _searchBar.text
if let myWebsite = NSURL(string: "\(_searchBar.text)")
{
let objectsToShare = [myWebsite]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
// The app is running on an iPad, so you have to wrap it in a UIPopOverController
var popOver: UIPopoverController = UIPopoverController(contentViewController: activityVC)
let rect = CGRect(origin: CGPoint(x: 559, y: 44), size: CGSize(width: 38, height: 32))
// if your "share" button is a UIBarButtonItem
popOver.presentPopoverFromRect(rect, inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
} else {
self.presentViewController(activityVC, animated: true, completion: nil)
}
}
}
1Password 扩展代码如下:
@IBAction func onePasswordButton(sender: AnyObject) {
OnePasswordExtension.sharedExtension().fillItemIntoWebView(self._webView, forViewController: self, sender: sender, showOnlyLogins: false, completion: {(Bool) in
// error handling
})
}
我尝试使用 UIActivityViewController 的 applicationActivities 部分中的扩展代码,但它不起作用(构建失败)。
是否可以在 ActivityViewController 中添加 1Password 扩展?
谢谢,
PastaCoder
【问题讨论】:
标签: ios objective-c swift uiactivityviewcontroller ios8-extension