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
EDIT 1 Apple has acknowledged my bug report and merged it with another bug report.
I've done a bit of testing, and found that this issue / bug is only prevalent with the iOS 8 simulator, and UIContentSizeCategoryDidChangeNotification
. Other notifications works as intended, and the UIContentSizeCategoryDidChangeNotification
is behaving as expected in the iOS 7 simulator. I have submitted a bug-report in radar. Hope this clarifies for people having this issue in the near future.
EDIT 2
This now seems to have been fixed. Further more, this library from Big Nerd Ranch really eases the whole process of setting up dynamic type.