为什么我使用UIImagePickerController获取内存错误?

时间:2011-06-13 01:24:05

标签: iphone ios

当我加载我的UIImagePickerController时,我得到了:

warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3 (8F190)/Symbols/System/Library/Frameworks/IOKit.framework/IOKit (file not found).
warning: Tried to remove a non-existent library: /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3 (8F190)/Symbols/System/Library/Frameworks/IOKit.framework/IOKit
2011-06-12 20:21:23.210 myapp[919:707] Received memory warning. Level=1

当我拍摄快照时,我会收到内存警告级别2.

这是我的代码:

#import <UIKit/UIKit.h>


    @interface SnapShotViewController : UIViewController<UINavigationControllerDelegate,UIImagePickerControllerDelegate> {

        IBOutlet UIButton *button;
        IBOutlet UIImageView *image;
        UIImagePickerController *imgPicker;

    }

    - (IBAction)grabImage;
    - (IBAction)useImage;

    @property (nonatomic, retain) UIImagePickerController *imgPicker;
    @property (nonatomic,retain)UIImageView *image;
    @property (nonatomic,retain)UIButton *button;

    @end



    #import "SnapShotViewController.h"


    @implementation SnapShotViewController

    @synthesize imgPicker, image, button;


    - (IBAction)grabImage{

        [self presentModalViewController:self.imgPicker animated:YES];

    }

    - (IBAction)useImage{
        NSLog(@"entering useImage...");

        if (image==nil) {
            UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"No Image Selected" 
                                                                     delegate:nil 
                                                            cancelButtonTitle:@"OK" 
                                                       destructiveButtonTitle:nil 
                                                            otherButtonTitles:nil];

            [actionSheet showInView:[[self view]window]];
            [actionSheet autorelease];
        }


    }



    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
        [image setImage:img];
        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }

    // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    /*
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization.
        }
        return self;
    }
    */


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


        self.imgPicker = [[UIImagePickerController alloc] init];
        //self.imgPicker.allowsImageEditing = YES;
        imgPicker.delegate =self;

        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])  {

            self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;

        }else

        self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }


    /*
    // Override to allow orientations other than the default portrait orientation.
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations.
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    */

    - (void)didReceiveMemoryWarning {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];

        // Release any cached data, images, etc. that aren't in use.
    }

 - (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;

    self.image = nil;
    self.button = nil;


}


- (void)dealloc {

    [imgPicker release];
    [image release];
    [button release];

    [super dealloc];
}


    @end

0 个答案:

没有答案
相关问题