我一直在尝试让我的应用程序从照片库中选择一张照片然后显示它,它在另一个项目中运行良好,但是在这个项目中应用程序运行良好但是当我按下应该显示的 UIButton画廊,我在 int retVal = UIApplicationMain(argc, argv, nil, nil); 上的 main.m 中收到错误 SIGABRT;
正如我所说,这在过去运行良好,所以我不知道为什么现在不行,这是与错误相关的代码部分,我只是发布它,因为我有很多代码这样更容易。
视图控制器.h
#import <UIKit/UKit.h>
@interface ViewController : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
//Blah blah blah
}
//Blah blah blah
-(IBAction) selectExistingpicture;
@property (nonatomic, retain) IBOutlet UIImageView *theImageView;
//Blah blah blah
@end
视图控制器.m
#import "ViewController.h"
@implementation ViewController
@synthesize theImageView;
-(IBAction) selectExistingPicture
{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage : (UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
theImageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
[picker dismissModalViewControllerAnimated:YES];
}
我已将 selectExistingPicture 链接到 UIButton,但我不知道是什么导致该按钮导致我出错。
任何帮助是极大的赞赏。