1
공간을 절약하기 위해 확대/축소되는 오늘의 확장 기능을 만들고 있습니다. 알림 센터에 있지만 NSNotificationCenter에 문제가 있습니다. visibility() 함수를 호출하면보기가 축소되어 정상적으로 커지지 만 알림을 게시하려고하면 확장 프로그램이 실패하고 대신에 다시로드하려고 시도합니다. (처음에는 확장 프로그램이 두 번째로 '로드 할 수 없습니다'라는 메시지가 표시됩니다. ". 왜 통지 방법이?오늘 NSNotificationCenter로 확장 기능이 깨졌습니다.
var NSNotificationDidChoose = "NSNotificationDidChoose"
@IBOutlet var tableView: UITableView!
@IBOutlet var activityIndicator: UIActivityIndicatorView!
@IBAction func shrink(sender: AnyObject) {
//visibility(["bool":false])works fine here
NSNotificationCenter.defaultCenter().postNotificationName(NSNotificationDidChoose, object: nil, userInfo: ["bool":false])
//Crashes and the extension reloads
}
@IBAction func unshrink(sender: AnyObject) {
//visibility(["bool":true]) works fine here
NSNotificationCenter.defaultCenter().postNotificationName(NSNotificationDidChoose, object: nil, userInfo: ["bool":true])
//Crashes and the extension reloads
}
@IBOutlet var buttonview: UIView!
func visibility(boole:[NSObject:AnyObject]) {
var bool = boole["bool"] as Bool
println(bool)
tableView.hidden = !bool
activityIndicator.hidden = !bool
if bool {
self.preferredContentSize = CGSize(width: 350, height: 420)
} else {
self.preferredContentSize = CGSize(width: 350, height: buttonview.frame.height+25)
}
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "visibility:", name: NSNotificationDidChoose, object: nil)
}