저는 Xcode 5에서 첫 IOS 7 iPad 앱을 제작하고 있습니다.하지만이 문제에 대한 도움이 필요합니다. 나는 꽤 작가와 함께 무엇을 의미하는지 이해하지UIImagePickerController를 사용한 NSException
:
나는 this 튜토리얼 다음과 같은거야. "그래서 testPickerViewController.h을 열고 우리가 클래스 참조에 다음에 추가 할" 을
UINavigationControllerDelegate, UIImagePickerControllerDelegate>
여기 내보기 controller.h 파일을 가지고 :
내보기 controller.m 파일#import "ViewController.h"
@interface DetailViewController : ViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
UIImagePickerController *imgPicker;
IBOutlet UIImageView *customImage;
}
@property(nonatomic, retain)UIImagePickerController *imgPicker;
@end
: 나는 정상에 쓴하지 않고 응용 프로그램을 실행
#import "DetailViewController.h"
@interface DetailViewController()
@end
@implementation DetailViewController
@synthesize imgPicker, customImage;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// Init the image picker
self.imgPicker = [[UIImagePickerController alloc]init];
self.imgPicker.allowsEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)AddImage:(id)sender {
// Let the user add an image for the specific subject
[self presentModalViewController:self.imgPicker animated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editingInfo {
customImage.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
@end
, 이로 인해 main.m 파일에 NSException이 발생했습니다.
내가 뭘 잘못하고 있니?
편집
main.m
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
편집
2014년 5월 17일 14 : 56 : 47.509을 myApp [1,424 : 60B] 앱 종단 * 의한 캐치되지 않는 예외 'NSUnknownKeyException'로, 이유 : '[setValue : forUndefinedKey :] :이 클래스는 키 이미지에 대해 키 값을 코딩하지 않습니다.'
예외 메시지는 ...입니까? –
NSException – Erik
의 catch되지 않은 예외로 종료하면 중단 점을 넣었으며이 경우 예외를 발생시키는 행을 확인 했습니까? –