UIImagePickerController crash tylko na iOS 7-iPad

Dostaję setki awarii z jednej z moich aplikacji na żywo, odkąd ludzie zaczęli uaktualniać do iOS 7. Czy ktoś jeszcze widział ten problem? Nic nie odtwarza się na moim iPadzie 3 z iOS 7...

Link do 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
Author: jjxtra, 2013-09-22

3 answers

Wspólnie doszliśmy do wniosku, że jest to błąd w iOS 7 na iPadzie. Występuje przy próbie pokazania UIImagePickerController w UIPopoverControl z UIBarButtonItem po raz pierwszy. Po udzieleniu zgody przez użytkownika na album ze zdjęciami następuje awaria. Wygląda na to, że rozwiązaniem na razie jest poproszenie o pozwolenie na zdjęcia przed otwarciem UIPopoverControl. Oto jak zaimplementowałem moje rozwiązanie:

// 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];
            });
        }];
    }
}

Nie zapomnij dodać AssetsLibrary.ramy do twojego projekt.

 16
Author: kurtzmarc,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-14 13:25:04

Miałem ten sam problem.

Miałem UIImagePickerController wyświetlany wewnątrz UIPopoverController z rozmiarem zdefiniowanym przez UIImagePickerController contentSizeForViewInPopover funkcji.
Aby rozwiązać ten problem zmieniłem Rozmiar {[1] } na UIImagePickerController's preferredContentSize function.

 0
Author: fnxpt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-04 11:16:05

Możesz użyć niestandardowej ramki i załadować popover jak poniżej

[popOver presentPopoverFromRect:CGRectMake(self.view.frame.size.width-50, 50, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
 0
Author: Yatin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-04 11:23:06