IOS 8 dynamic type with static cell TableView - main and subtitle

After resizing the text in settings and returning to the application, the static cells of type Basic and Subtitle and left blank until you step back from the view or reload the application. A custom static cell retains its text.

Simple replication.

Create one view app, replace UIViewController with UiTableViewController. Change the content from dynamic to static cells.

Set style cell 0 = custom, cell 1 = base and cell 2 = subtitles

Binding properties for everyone

@property (weak, nonatomic) IBOutlet UILabel *customCell;
@property (weak, nonatomic) IBOutlet UILabel *basicCell;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;


add the following to view DidLoad

NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(updateInterfaceForDynamicTypeSize)      name:UIContentSizeCategoryDidChangeNotification object:nil];

self.customCell.text = @"Custom Cell";
self.basicCell.text = @"Basic Cell";
self.titleLabel.text = @"My Title";
self.subTitleLabel.text = @"My Sub Title";


add the following method

-(void)updateInterfaceForDynamicTypeSize {
UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.customCell.font = font;
self.basicCell.font = font;
self.titleLabel.font = font;
font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
self.subTitleLabel.font = font;
[self.tableView reloadData];


Launch the app - then go to Settings and resize the text. Go back to the app and only the content of the custom cell is displayed.

This was not the case with IOS 7. Am I missing something here or is this a bug?


source to share

1 answer

Customize your cell in storyboard to use a custom class instead of the default UITableViewCell

A simple custom element is implemented like this:

// DynamicTypeResistantCell.h
#import <UIKit/UIKit.h>
@interface DynamicTypeResistantCell : UITableViewCell


// DynamicTypeResistantCell.m
@implementation DynamicTypeResistantCell
- (void)_systemTextSizeChanged
    // don't call super!


Then you can safely use the Basic and Subtitle styles and the cell will keep their contents after the dynamic type is resized.



All Articles