15

人々が iOS 7 にアップグレードし始めて以来、ライブ アプリの 1 つで何百回もクラッシュが発生しています。この問題を見た人はいますか? iOS 7 を搭載した iPad 3 で何も再生されません...

Crashlytics へのリンク: crashes.to/s/edf2e71d9a5

Fatal Exception CALayerInvalidGeometry
CALayer position contains NaN: [nan nan]
0 ...    CoreFoundation  __exceptionPreprocess + 130
2    CoreFoundation  -[NSException initWithCoder:]
3    QuartzCore      CA::Layer::set_position(CA::Vec2<double> const&, bool) + 242
4    QuartzCore  -[CALayer setPosition:] + 54
5    QuartzCore  -[CALayer setFrame:] + 594
6    UIKit   -[UIView(Geometry) setFrame:] + 254
7    UIKit   -[UILabel setFrame:] + 138
8    UIKit   -[UINavigationItemView initWithNavigationItem:] + 384
9    UIKit   -[UINavigationItem _titleView] + 92
10   UIKit   -[UINavigationBar _prepareForPushAnimationWithItems:] + 68
11   UIKit   -[UINavigationBar pushNavigationItem:] + 292
12   UIKit   -[UINavigationBar _pushNavigationItem:transition:] + 386
13   UIKit   __71-[UINavigationController pushViewController:transition:forceImmediate:]_block_invoke + 150
14   UIKit   -[UINavigationController pushViewController:transition:forceImmediate:] + 1384
15   UIKit   -[UINavigationController pushViewController:animated:] + 294
16   UIKit   -[UIImagePickerController _setupControllersForCurrentSourceType] + 112
17   UIKit   -[UIImagePickerController setSourceType:] + 456
18 ...   libdispatch.dylib   _dispatch_call_block_and_release + 10
19   libdispatch.dylib   _dispatch_client_callout + 22
20   libdispatch.dylib   _dispatch_main_queue_callback_4CF$VARIANT$mp + 268
21   CoreFoundation  __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
22   CoreFoundation  __CFRunLoopRun + 1300
23   CoreFoundation  CFRunLoopRunSpecific + 522
24   CoreFoundation  CFRunLoopRunInMode + 106
25   GraphicsServices    GSEventRunModal + 138
26   UIKit   UIApplicationMain + 1136
4

3 に答える 3

16

これは iPad 上の iOS 7 のバグであるという結論に達しました。これは、UIBarButtonItem から UIPopoverControl に UIImagePickerController を初めて表示しようとしたときに発生します。ユーザーがフォト アルバムへのアクセス許可を付与すると、クラッシュが発生します。今のところ解決策は、UIPopoverControl を開く前に写真への許可を要求することです。ソリューションを実装する方法は次のとおりです。

// Photo Library
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
    void(^blk)() =  ^() {
        UIImagePickerController* picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        if (NIIsPad()) {
            UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController:picker];
            [popover presentPopoverFromBarButtonItem:self.popoverAnchor permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        } else {
            [self.navigationController presentModalViewController:picker animated:YES];
        }
    };

    // Make sure we have permission, otherwise request it first
    ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
    ALAuthorizationStatus authStatus;
    if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
        authStatus = [ALAssetsLibrary authorizationStatus];
    else
        authStatus = ALAuthorizationStatusAuthorized;

    if (authStatus == ALAuthorizationStatusAuthorized) {
        blk();
    } else if (authStatus == ALAuthorizationStatusDenied || authStatus == ALAuthorizationStatusRestricted) {
        [[UIAlertView alertViewWithTitle:@"Grant photos permission" message:@"Grant permission to your photos. Go to Settings App > Privacy > Photos."] show];
    } else if (authStatus == ALAuthorizationStatusNotDetermined) {
        [assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
            // Catch the final iteration, ignore the rest
            if (group == nil)
                dispatch_async(dispatch_get_main_queue(), ^{
                    blk();
                });
            *stop = YES;
        } failureBlock:^(NSError *error) {
            // failure :(
            dispatch_async(dispatch_get_main_queue(), ^{
                [[UIAlertView alertViewWithTitle:@"Grant photos permission" message:@"Grant permission to your photos. Go to Settings App > Privacy > Photos."] show];
            });
        }];
    }
}

AssetsLibrary.framework をプロジェクトに追加することを忘れないでください。

于 2013-09-26T01:32:54.423 に答える