I'm currently developing in Swift and have run into a problem with the dynamic typing. I have set this code
import Foundation
import UIKit
class ExerciseController :UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet var exerciseTableView :UITableView
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "reload", name: UIContentSizeCategoryDidChangeNotification, object: nil)
}
override func viewWillDisappear(animated: Bool) {
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIContentSizeCategoryDidChangeNotification, object: nil)
}
func reload() {
println("reload")
}
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
return 1
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cellIdentifier = "ExerciseCell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as? UITableViewCell
if !cell {
cell = UITableViewCell(style: .Default, reuseIdentifier: cellIdentifier)
}
cell!.textLabel.text = "Hello"
cell!.textLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
return cell
}
}
I run my app, and then go to the Settings app to modify the text size, but the notification selector is not getting called and have no idea why. Thanks in advance in resolving this issue, all help is appreciated
*Previously the notification observers where set on viewDidiLoad and deinit but it didn't work either
UPDATE #1
I tried the same thing with the keyboard notification and it did work. That would mean that the application is not recognizing when the text size change when it is done