一部のベータテスターでCrittercismを使用しています私は自分自身を経験したことがなく、複製できないエラーが数回現れています。NSInternalInconsistencyException _cachedSystemAnimationFenceにアクセスするにはメインスレッドが必要
Crittercismが私に語った:NSInternalInconsistencyExceptionは_cachedSystemAnimationFenceにアクセスすると、メインスレッド
を必要とし、それが指している行がある:
[picker dismissViewControllerAnimated:YES completion:^{
StackOverflowの上でいくつかの読書を行うには、任意のUIコードは上の実行されなければならないことが表示されますメインスレッドdismissViewControllerAnimatedがバックグラウンドスレッドで実行されたために発生したエラーですか?
このエラーが比較的ランダムである(つまり再現できない)と、それを修正する方法が不思議です。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
__block PHObjectPlaceholder *assetPlaceholder;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];
assetPlaceholder = changeRequest.placeholderForCreatedAsset;
} completionHandler:^(BOOL success, NSError *error) {
NSArray *photos = [[NSArray alloc] initWithObjects:assetPlaceholder.localIdentifier, nil];
PHFetchResult *savedPhotos = [PHAsset fetchAssetsWithLocalIdentifiers:photos options:nil];
[savedPhotos enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {
NSMutableArray *images = self.event.eventAttachments;
if (images) {
[images addObject:asset];
} else {
images = [[NSMutableArray alloc]init];
[images addObject:asset];
}
self.event.eventAttachments = images;
[picker dismissViewControllerAnimated:YES completion:^{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:4];
NSArray *indexPaths = [[NSArray alloc] initWithObjects:indexPath, nil];
[self.tblChildrenNotes beginUpdates];
[self.tblChildrenNotes reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
[self.tblChildrenNotes endUpdates];
}];
}];
}];
}
この問題は修正されましたか?または、あなたが提供できるソリューション? –
バックグラウンドスレッドでUIを操作しようとするコードが必要です。ユーザー 'iOS'が投稿したコードスニペットにUI操作をラップする – jungledev