首页 > 代码库 > iOS 经验总结

iOS 经验总结

1.主线程在动画未结束时进行操作可能导致应用崩溃

如下,当dismissViewControllerAnimated:为YES时,由于后续有页面显示,就在应用中导致了崩溃

- (void)imagePickerController:(UIImagePickerController *)picker

didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];

    self.decoding = YES;

    [picker dismissViewControllerAnimated:NO completion:nil];

    

    __block ZXingWidgetController *tempSelf = self;

    tempSelf.imageDecoder = [tempSelf decodeImage:image cropRect:CGRectZero];

}

 2.当发现界面未按代码运行进行刷新时,如tableview reloaddata,界面未刷新,可能是因为reloaddata不是在主线程导致

iOS 经验总结