Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS 8动态类型,带静态TableView单元格-基本和字幕_Ios_Objective C_Uitableview - Fatal编程技术网

IOS 8动态类型,带静态TableView单元格-基本和字幕

IOS 8动态类型,带静态TableView单元格-基本和字幕,ios,objective-c,uitableview,Ios,Objective C,Uitableview,在“设置”中更改文本大小并返回应用程序后,Basic和Subtitle类型的静态单元格将保留为空,直到您离开视图或重新加载应用程序。自定义静态单元格保留其文本 复制起来很简单 创建单视图应用程序,将UIViewController替换为UiTableViewController。 将内容从动态单元格更改为静态单元格 设置样式单元格0=自定义,单元格1=基本,单元格2=字幕 所有连接属性 @property (weak, nonatomic) IBOutlet UILabel *customCel

在“设置”中更改文本大小并返回应用程序后,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并非如此。我在这里遗漏了什么还是这是一个bug?

在情节提要中配置您的单元格以使用自定义类而不是默认的
UITableViewCell

简单的自定义单元实现如下:

//DynamicTypeResistantCell.h
#进口
@接口动态TypeResistantCell:UITableViewCell
@结束
//DynamicTypeResistantCell.m
@动态TypeResistantCell的实现
-(无效)\系统文本大小已更改
{
//不要叫超级!
}
@结束
然后可以安全地使用基本样式和字幕样式,并在动态类型大小更改后保留其内容