근무 중 Share extension
& 관련 질문이 하나 있습니다.팝업 확장자 대신 전체보기 컨트롤러를 열 수 있습니까? (기본값)
공유 확장에서 전체보기 컨트롤러를 열 수 있습니까? UITableView
또는 기타 IBoutlet
을 Storyboard
을 사용하여 Share extension
에 추가 할 수 있습니까? 사전
근무 중 Share extension
& 관련 질문이 하나 있습니다.팝업 확장자 대신 전체보기 컨트롤러를 열 수 있습니까? (기본값)
공유 확장에서 전체보기 컨트롤러를 열 수 있습니까? UITableView
또는 기타 IBoutlet
을 Storyboard
을 사용하여 Share extension
에 추가 할 수 있습니까? 사전
1 단계에서
감사 :이 UIViewController
가 MainPageViewController
라는 이름의 새로운 추가합니다.
2 단계 : MainInterface
스토리 보드에서 추가 새로운 뷰 컨트롤러, 스토리 보드의 사용자 정의 클래스 섹션에서 MainPageViewController
에의 클래스를 변경, 신원 섹션에서 MainPageViewController
에 Storyboard ID
을 설정합니다.
3 단계는 : 열기 공유 확장의는의 Info.plist
은 기본적으로는, 이제 대신 기본 NSExtensionMainStoryboard
키 사용 NSExtensionPrincipalClass
키 this-
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>TRUEPREDICATE</string>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
같이 보입니다 최종 결과 때문에 될 것이다
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>TRUEPREDICATE</string>
</dict>
<key>NSExtensionPrincipalClass</key>
<string>HomeViewController</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
여기서 HomeViewController
은 새로운 엔트리 포인트 컨트롤러입니다.
4 단계는 : 이제, 가장 중요한 우리는 fix weird issue related with module naming해야합니다.
수정하려면 HomeViewController
파일 상단에 @objc(HomeViewController)
을 추가해야합니다.
5 단계 : MainPageViewController
이의 식별자가
import UIKit
@objc(HomeViewController)
class HomeViewController : UINavigationController {
init() {
let viewController:UIViewController = UIStoryboard(name: "MainInterface", bundle: nil).instantiateViewController(withIdentifier: "MainPageViewController") as UIViewController
super.init(rootViewController: viewController)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.size.height)
UIView.animate(withDuration: 0.25, animations: {() -> Void in
self.view.transform = CGAffineTransform.identity
})
}
}
인 경우 : 또한 프레젠테이션을 애니메이션하기 위해, 우리는 참조 코드 아래 참조 viewWillAppear
에 애니메이션 코드를 추가해야 귀하의
MainViewController
을 제출하셔야합니다.STEP6 : 우리가
MainPageViewController
클래스에 새로운 기능을 만들 수 있습니다 애니메이션을 해제하려면 : 저장에 FUNC 위func hideExtensionWithCompletionHandler(completion:@escaping (Bool) -> Void) { UIView.animate(withDuration: 0.20, animations: { self.navigationController!.view.transform = CGAffineTransform(translationX: 0, y: self.navigationController!.view.frame.size.height) }, completion: completion) }
전화 또는 취소 버튼을 블록 내부에, 우리가 호출 할 수
completeRequest
또는cancelRequest(withError:)
func saveButtonTapped(sender: UIBarButtonItem) { self.hideExtensionWithCompletionHandler(completion: { (Bool) -> Void in self.extensionContext!.completeRequest(returningItems: nil, completionHandler: nil) }) }
자, 이제 뭐든지하고 싶은 일을하십시오. 두 사람을하세요 ;-)
예, whatsapp이 작업을 수행합니다. –
이것 좀보세요. 이것은 구버전의 구버전이지만 도움을받을 수 있습니다. https://github.com/martinnormark/ShareByMail –