強制プレスリッチ通知を利用するiOS 10にカスタム通知を追加しようとしています。UNNotificationContentExtension から継承するビュー コントローラーの中央にプログラムでビューを追加したいのですが、白い画面しか表示されません。次のようなフレームを指定すると、コンテンツが追加されます。
import UIKit
import UserNotifications
import UserNotificationsUI
class NotificationViewController: UIViewController, UNNotificationContentExtension {
override func viewDidLoad() {
super.viewDidLoad()
let myView = UIView()
myView.backgroundColor = UIColor.red
myView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
self.view.addSubview(myView)
}
func didReceive(_ notification: UNNotification) {
}
}
次のようになります:
しかし、このコードを使用して (PureLayout ラッパーを使用して) プログラムで AutoLayout を使用しようとすると:
import UIKit
import UserNotifications
import UserNotificationsUI
class NotificationViewController: UIViewController, UNNotificationContentExtension {
override func viewDidLoad() {
super.viewDidLoad()
let myView = UIView()
myView.backgroundColor = UIColor.red
self.view.addSubview(myView)
myView.autoPinEdge(toSuperviewEdge: .top)
myView.autoPinEdge(toSuperviewEdge: .left)
myView.autoMatch(.width, to: .width, of: self.view)
myView.autoMatch(.height, to: .height, of: self.view)
}
func didReceive(_ notification: UNNotification) {
}
}
このView ControllerでAutoLayoutが機能しない原因は何ですか? インターフェイスビルダーでもテストしたので、かなり混乱しています。