提交
This commit is contained in:
@@ -148,11 +148,24 @@
|
||||
showToast(@"请选择PK时长");
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[QXMineNetwork roomPkStartWithPk_id:self.pkId pk_times:self.timeModel.relation_id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
[weakSelf hide];
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
NSLog(@"⚠️ self has been deallocated, skipping hide operation");
|
||||
return;
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
[strongSelf hide];
|
||||
}
|
||||
});
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
// 错误回调也要确保在主线程
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
showToast(msg);
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -220,10 +233,21 @@
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
if (!self.superview) {
|
||||
NSLog(@"⚠️ View already removed from superview");
|
||||
return;
|
||||
}
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
if (self.bgView) {
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
}
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
// 检查是否已经被移除
|
||||
if (self.superview) {
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
// 避免在 dealloc 过程中访问其他属性
|
||||
// 不要在 completion block 中访问或设置其他属性
|
||||
}];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user