Skip to content

Commit

Permalink
fix: cannot remove self.subviews in updateConstraints
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed May 2, 2024
1 parent 313c17b commit bab4b1f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Easydict/objc/ViewController/View/Titlebar/EZTitlebar.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,23 @@ - (void)setup {
[defaultCenter addObserver:self selector:@selector(updateConstraints) name:NSNotification.languagePreferenceChanged object:nil];
}

//- (void)update

- (void)updateConstraints {
/**
Fix appcenter issue, seems cannot remove self.subviews 🤔
-[EZTitlebar updateConstraints]
EZTitlebar.m, line 64
SIGABRT: *** Collection <__NSArrayM: 0x6000036e45d0> was mutated while being enumerated.
*/

// Remove and dealloc all views to refresh UI.
for (NSView *subview in self.subviews) {
[subview removeFromSuperview];
}

[_pinButton removeFromSuperview];
[_stackView removeFromSuperview];
_stackView = nil;
_quickActionButton = nil;

[self addSubview:self.pinButton];
[self updatePinButton];
Expand Down

0 comments on commit bab4b1f

Please sign in to comment.