1

我为 Ios5-6 编写了一个小型单视图应用程序,它允许用户捕获照片图像,然后将所述图像设置为图像视图。ImagePicker 视图打开得很好,但是当我单击捕获应用程序关闭时,我收到以下控制台输出。(该应用程序在 ios 模拟器 6 中运行时按预期工作。在 iphone4s 设备上出现故障)

2013-01-25 15:21:11.129 LearningPhotos[10914:707] 找不到映射图像 Silver_ISXSilent.png 2013-01-25 15:21:11.250 LearningPhotos[10914:707] 找不到映射图像 ColorOnGrayShadow_ISXSilent.png 2013- 01-25 15:21:16.678 LearningPhotos[10914:707] 收到内存警告。

视图控制器接口:

    //
//  ViewController.h
//  LearningPhotos
//
//  Created by Jared Rainey on 1/24/13.
//  Copyright (c) 2013 Volatile App Group. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UINavigationControllerDelegate, UIImagePickerControllerDelegate>{

    UIImagePickerController *imagePicker;
    UIImage *image;
}

@property (strong, nonatomic) IBOutlet UILabel *imageLabel;
@property (strong, nonatomic) IBOutlet UIImageView *imageView;

- (IBAction)imageButton:(id)sender;

@end

视图控制器实现:

    //
//  ViewController.m
//  LearningPhotos
//
//  Created by Jared Rainey on 1/24/13.
//  Copyright (c) 2013 Volatile App Group. All rights reserved.
//

#import "ViewController.h"
#import "AFHTTPClient.h"

@implementation ViewController


@synthesize imageView,imageLabel;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    imagePicker = [[UIImagePickerController alloc]init];

    //If Camera source type available use it otherwise photo library
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
        imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
    }else{
        [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    }

    //allow no image editing
    [imagePicker setAllowsEditing:NO];

    //set imagepickercontroller delegate to self
    [imagePicker setDelegate:self];     
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)imageButton:(id)sender {
    //Image Button has been pressed
    //load image picker view dependent on UIImagePickerController source type
    [self presentModalViewController:imagePicker animated:YES];
}

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    image = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];
    imageView.image = image;
    [picker dismissModalViewControllerAnimated:YES];


}

-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [picker dismissModalViewControllerAnimated:YES];
}

@end

设备日志:

Incident Identifier: 6084670F-7944-4D19-8953-A9582801A161
CrashReporter Key:   e3fd67afdfbdcc8a506fa6b75e4c965b76c10346
Hardware Model:      iPhone4,1
OS Version:          iPhone OS 5.1.1 (9B206)
Kernel Version:      Darwin Kernel Version 11.0.0: Sun Apr  8 21:51:47 PDT 2012; root:xnu-1878.11.10~1/RELEASE_ARM_S5L8940X
Date:                2013-01-25 16:42:36 -0500
Time since snapshot: 43 ms

Free pages:        812
Active pages:      3403
Inactive pages:    1987
Throttled pages:   97220
Purgeable pages:   127
Wired pages:       25283
Largest process:   SpringBoard

Processes
         Name                 UUID                    Count resident pages
  LearningPhotos <4965639c91ae38ae9d40911923ef0502>   10251 (jettisoned) (active)
     debugserver <2408bf4540f63c55b656243d522df7b2>     163
        installd <0f9e14173c503a8089f7f8cd0329a1a0>     548
      MobileMail <eed7992f4c1d3050a7fb5d04f1534030>    1386 (jettisoned)
     MobilePhone <8f3f3e982d9235acbff1e33881b0eb13>    1123 (jettisoned)
            ptpd <62bc5573db7a352ab68409e87dc9abb9>     494
springboardservi <b74f5f58317031e9aef7e95744c816ca>     307
notification_pro <373a488638c436b48ef0801b212593c4>     106
notification_pro <373a488638c436b48ef0801b212593c4>     110
             atc <1e5f2a595709376b97f7f0fa29368ef1>     652
notification_pro <373a488638c436b48ef0801b212593c4>      95
notification_pro <373a488638c436b48ef0801b212593c4>     102
    syslog_relay <b07876a121a432d39d89daf531e8f2bd>      74
            afcd <c3cc9d594b523fd1902fb69add11c25d>     126
     dataaccessd <473ff40f3bfd3f71b5e3b4335b2011ee>     903
    mediaserverd <f03b746f09293fd39a6079c135e7ed00>    1146
      aosnotifyd <8cf4ef51f0c635dc920be1d4ad81b322>     419
            iapd <0a747292a113307abb17216274976be5>     564
   absinthed.N94 <2e1b2b6827f73747a686445a7a4d2db9>     115
        SCHelper <9b0b21c547c23b8a876271fee80f037a>     139
        networkd <80ba40030462385085b5b7e47601d48d>     165
            flux <204b55baaf0b372789e1a4da2b1c73e3>     389
        BTServer <31e82dfa7ccd364fb8fcc650f6194790>     576
      aggregated <a12fa71e6997362c83e0c23d8b4eb5b7>     413
            apsd <e7a29f2034083510b5439c0fb5de7ef1>     312
   fairplayd.N94 <e69a54203b7b3293ad3b0f8d83fa3ce1>     161
       fseventsd <914b28fa8f8a362fabcc47294380c81c>     179
         imagent <9c3a4f75d1303349a53fc6555ea25cd7>     866
   mDNSResponder <86ccd4633a6c3c7caf44f51ce4aca96d>     237
    mediaremoted <327f00bfc10b3820b4a74b9666b0c758>     290
           wifid <3001cd0a61fe357d95f170247e5458f5>     365
     sbsettingsd <e9a2c6b3c8a722b2bae7541bb247b81d>     334
    springflashd <3927dd5f9d5d3e3785a411a3283b4253>     374
       locationd <cf31b0cddd2d3791a2bfcd6033c99045>    1194
       ISXDaemon <54a1918090fb3c81acbd60b283de91a5>     263
          powerd <133b7397f5603cf8bef209d4172d6c39>     173
       lockdownd <b06de06b9f6939d3afc607b968841ab9>     268
      CommCenter <2c0aa3aba43a394d86f294959dbc61bd>     966
     SpringBoard <c74dc89dec1c3392b3f7ac891869644a>   42475 (active)
         configd <ee72b01d85c33a24b3548fa40fbe519c>     658
         syslogd <7153b590e0353520a19b74a14654eaaa>     229
         notifyd <f6a9aa19d33c3962aad3a77571017958>     275
  UserEventAgent <dc32e6824fd33bf189b266102751314f>     402
         launchd <5fec01c378a030a8bd23062689abb07f>     175

**End**

任何帮助将不胜感激。我是 ios 开发的新手,我期待着解决这个问题,因为我一直在尝试我可以在论坛中找到的所有内容。

提前致谢,

4

2 回答 2

0

由于内存警告,您可能会崩溃。尽量不要保存每张图像,因为它可能对后置高分辨率相机重 2-3 Mb,或者以某种方式回收内存。

于 2013-04-09T15:06:37.660 回答
0

这是我的猜测:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    imageView.image = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissModalViewControllerAnimated:YES];    
}

您的图像变量可能不会保留您从信息中获得的图像。它可能会崩溃,因为您在关闭选择器视图控制器后设置了 imageview 的图像。

于 2013-01-25T20:44:54.333 回答