Tus*_*iya 7 iphone ios swift ios8-share-extension
我是iOS应用开发的初学者,我想在另一个应用的复制链接上启动我的应用。单击时添加共享扩展名,它显示弹出窗口。但是我的要求是它不应该显示弹出窗口,并且单击共享扩展名直接打开我的应用程序。
我做了什么:
1)在info.plist中添加了规则
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
Run Code Online (Sandbox Code Playgroud)
短屏幕 :
更新:添加下面的代码后,弹出窗口不会出现,但我的应用程序无法打开
目标C:
- (BOOL)isContentValid {
return YES;
}
#ifdef HIDE_POST_DIALOG
- ( NSArray * ) configurationItems
{
return @[];
}
#endif
- ( void ) didSelectPost
{
#ifdef HIDE_POST_DIALOG
return;
#endif
}
CGFloat m_oldAlpha = 1.0;
#ifdef HIDE_POST_DIALOG
- ( void ) willMoveToParentViewController: ( UIViewController * ) parent
{
m_oldAlpha = [ self.view alpha ];
[ self.view setAlpha: 0.0 ];
}
#endif
#ifdef HIDE_POST_DIALOG
- ( void ) didMoveToParentViewController: ( UIViewController * ) parent
{
// Restore the original transparency:
[ self.view setAlpha: m_oldAlpha ];
}
#endif
#ifdef HIDE_POST_DIALOG
- ( id ) init
{
if ( self = [ super init ] )
{
[ [ NSNotificationCenter defaultCenter ] addObserver: self selector: @selector( keyboardWillShow: ) name: UIKeyboardWillShowNotification object: nil ];
}
return self;
}
#endif
#ifdef HIDE_POST_DIALOG
- ( void ) keyboardWillShow: ( NSNotification * ) note
{
[ self.view endEditing: true ];
}
#endif
Run Code Online (Sandbox Code Playgroud)
斯威夫特:
override func isContentValid() -> Bool {
// Do validation of contentText and/or NSExtensionContext attachments here
return true
}
override func didSelectPost() {
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
}
override func viewDidAppear(_ animated: Bool) {
self.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.size.height)
UIView.animate(withDuration: 0.25, animations: { () -> Void in
self.view.transform = .identity
})
}
Run Code Online (Sandbox Code Playgroud)
小智 -3
将其添加到您的共享视图控制器中。不客气。
override func viewDidAppear(_ animated: Bool) {
self.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.size.height)
UIView.animate(withDuration: 0.25, animations: { () -> Void in
self.view.transform = .identity
})
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
447 次 |
| 最近记录: |