小编rab*_*ace的帖子

为什么添加子图层会重叠子视图?

例如,我有一个UILabel作为子视图的视图.如果在某个时候我将具有一些背景颜色的子图层添加到此视图的图层,则此标签将消失.有人可以解释这种行为吗?

ios

20
推荐指数
2
解决办法
4316
查看次数

我应该在实现文件中使用nullable/nonnull吗?

我想使用Objective-C可空性功能.但是我应该使用nullable/nonnull实现文件或仅使用接口进行注释吗?

objective-c

14
推荐指数
1
解决办法
1147
查看次数

使用UITableViewAutomaticDimension时UITableViewCell高度错误

我使用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)

结果如下:

滚动后:

uitableview ios autolayout

7
推荐指数
1
解决办法
6742
查看次数

在NSUserDefaults中存储自定义对象时,应用程序崩溃

我有一个名为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)

xcode ios swift

5
推荐指数
1
解决办法
1661
查看次数

标签 统计

ios ×3

autolayout ×1

objective-c ×1

swift ×1

uitableview ×1

xcode ×1