【发布时间】:2014-10-11 11:28:40
【问题描述】:
在设置中更改文本大小并返回应用程序后,Basic 和 Subtitle 类型的静态单元格并留空,直到您离开视图或重新加载应用程序。自定义静态单元格保留其文本。
易于复制。
创建一个单视图应用,将 UIViewController 替换为 UiTableViewController。 将内容从动态单元格更改为静态单元格。
设置样式单元格 0 = 自定义,单元格 1 = 基本和单元格 2 = 字幕
为所有人连接属性
@property (weak, nonatomic) IBOutlet UILabel *customCell;
@property (weak, nonatomic) IBOutlet UILabel *basicCell;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;
将以下内容添加到 viewDidLoad
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";
添加以下方法
-(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];
}
运行应用程序 - 然后转到设置并更改文本大小。 返回应用程序,仅显示自定义单元格内容。
IOS 7 不是这种情况。我在这里遗漏了什么还是这是一个错误?
【问题讨论】:
标签: ios objective-c uitableview