例如,我有一个UILabel作为子视图的视图.如果在某个时候我将具有一些背景颜色的子图层添加到此视图的图层,则此标签将消失.有人可以解释这种行为吗?
我想使用Objective-C可空性功能.但是我应该使用nullable/nonnull实现文件或仅使用接口进行注释吗?
我使用2个多线标签制作自定义单元格,并将此标签固定到所有边.当在-tableView:heightForRowAtIndexPath:用于iOS的> = 8我返回UITableViewAutomaticDimension.但是当表视图出现时,单元格高度应该比应该大.向下滚动然后向上滚动单元格取正常高度.如何解决这个问题?
高度代码:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) {
return UITableViewAutomaticDimension;
}
static CCTopicTableViewCell *cell;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
cell = [tableView dequeueReusableCellWithIdentifier:@"topicCellIdentifier"];
});
cell.topic = [self.topics topicAtIndexPath:indexPath];
cell.bounds = CGRectMake(0, 0, CGRectGetWidth(self.tableView.bounds), CGRectGetHeight(cell.bounds));
[cell setNeedsLayout];
[cell layoutIfNeeded];
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height + 1;
}
Run Code Online (Sandbox Code Playgroud)
结果如下:

滚动后:

我有一个名为Userwitch的自定义类符合NSCoding协议.但是当我试图将它存储在NSUserDefaults中时,我收到此错误:
Property list invalid for format: 200
(property lists cannot contain objects of type 'CFType')
Run Code Online (Sandbox Code Playgroud)
这个警告:
NSForwarding: warning: object 0x7f816a681110 of class 'Shikimori.User'
does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[Shikimori.User _copyDescription]
Run Code Online (Sandbox Code Playgroud)
User 类:
class User: NSCoding {
private enum CoderKeys: String {
case ID = "user.id"
case Username = "user.username"
case Email = "user.email"
case Avatar = "user.avatar"
}
let id: Int
let username: String
let email: String
let avatar: String
init(id: Int, username: String, …Run Code Online (Sandbox Code Playgroud)