【问题标题】:After calling UIImagePickerController multiple times the device restarts多次调用 UIImagePickerController 后设备重启
【发布时间】:2012-01-01 04:00:16
【问题描述】:

我实现了 UIImagePickerController 委托、UINavigationController 委托、UIPopOverController 委托。我不知道问题是什么。我的设备在调用 3、4 或 5 次后重新启动(每个版本都不同)。请帮我解决它!

编辑:我收到此错误:

More than maximum 5 filtered album lists trying to register. This will fail.

这是我用来调用 UIImagePickerController 并获取图像的代码:

- (IBAction)imgPickerPressed:(id)sender {
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
        imgPickerTypeActionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose image source:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Photo Library", nil];
        [imgPickerTypeActionSheet showInView:self];
    }
    else {
        UIImagePickerController *controller = [[UIImagePickerController alloc] init];
        [controller setDelegate:self];
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
            [controller setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        }
        imgPickerPopOver = [[UIPopoverController alloc] initWithContentViewController:controller];
        imgPickerPopOver.delegate = self;
        [imgPickerPopOver presentPopoverFromRect:CGRectMake(imgPickerButton.frame.origin.x, imgPickerButton.frame.origin.x-250, 0.0, 0.0) 
                                          inView:self
                        permittedArrowDirections:UIPopoverArrowDirectionDown 
                                        animated:YES];
    }
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if ([actionSheet isEqual:imgPickerTypeActionSheet]) {
        if (buttonIndex == 0) {
            UIImagePickerController *controller = [[UIImagePickerController alloc] init];
            [controller setDelegate:self];
            [controller setSourceType:UIImagePickerControllerSourceTypeCamera];

            [[delegate getVC] presentModalViewController:controller animated:YES];
        }
        if (buttonIndex == 1) {
            UIImagePickerController *controller = [[UIImagePickerController alloc] init];
            [controller setDelegate:self];
            [controller setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

            imgPickerPopOver = [[UIPopoverController alloc] initWithContentViewController:controller];
            imgPickerPopOver.delegate = self;
            [imgPickerPopOver presentPopoverFromRect:CGRectMake(imgPickerButton.frame.origin.x, imgPickerButton.frame.origin.x-250, 1, 1) 
                                              inView:self
                            permittedArrowDirections:UIPopoverArrowDirectionDown 
                                            animated:YES];
        }
    }
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    [imgPickerPopOver dismissPopoverAnimated:YES];
    pickedImageView.image = image;
    [self valueChanged:nil];
}

【问题讨论】:

  • 设备重启是什么意思?我的意思是它会自动关闭并打开
  • 设备重启。实际设备重启,设备关机再开机
  • 我发现了一个错误但不知道如何解决
  • 超过 5 个过滤的专辑列表试图注册。这将失败。
  • 你没有提到你正在运行哪个设备,我的意思是 iPhone 3G、4G、4Gs blah blah

标签: iphone crash uiimage uiimagepickercontroller restart


【解决方案1】:

这在 iOS 模拟器中有效吗?您是否也在释放这些对象中的任何一个,还是 ARC 正在这样做? This 可能会有所帮助。

【讨论】:

  • ARC 正在这样做,是的,在模拟器中很好
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-28
  • 2017-06-01
相关资源
最近更新 更多