Skip to content

Crash在NSMutableArray+SafeKit.h 的-(void)SKaddObject:(id)anObject方法处 #6

@Ilikewhite

Description

@Ilikewhite

UIImageView在重置Constraints时,会有很高的概率crash。
我们的代码如下:先清除了自己之前的约束,然后重新增加新的约束,然后-(void)SKaddObject:(id)anObject报错,导致crash

    //经验值条增长动画
    [self.expLineImageView removeConstraints:self.expLineImageView.constraints];
    [self.expLineImageView addConstraint:[NSLayoutConstraint
                                             constraintWithItem:self.expLineImageView
                                                      attribute:NSLayoutAttributeHeight
                                                      relatedBy:NSLayoutRelationEqual
                                                         toItem:nil
                                                      attribute:0
                                                     multiplier:1
                                                       constant:2]];
    [self.expLineImageView addConstraint:[NSLayoutConstraint
                                             constraintWithItem:self.expLineImageView
                                                      attribute:NSLayoutAttributeWidth
                                                      relatedBy:NSLayoutRelationEqual
                                                         toItem:nil
                                                      attribute:0
                                                     multiplier:1
                                                       constant:320 * _levelPercent]];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions