Ipad iOS模拟器是否能够模拟设备';谁的照相机?
为了确保所有代码都正确,下面是我的头文件:Ipad iOS模拟器是否能够模拟设备';谁的照相机?,ipad,ios6,ios-simulator,uiimagepickercontroller,xcode4.5,Ipad,Ios6,Ios Simulator,Uiimagepickercontroller,Xcode4.5,为了确保所有代码都正确,下面是我的头文件: #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate> { IBOutlet UIImageView *imageView; IBOutlet UIButton *choosePhoto; I
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
IBOutlet UIImageView *imageView;
IBOutlet UIButton *choosePhoto;
IBOutlet UIButton *takePhoto;
}
@property(nonatomic, retain) UIButton *choosePhoto;
@property(nonatomic, retain) UIButton *takePhoto;
@property(nonatomic, retain) UIImageView *imageView;
-(IBAction)getPhoto:(id)sender;
-(IBAction)takePhoto:(id)sender;
@end
我的界面生成器中有两个ui按钮
和一个uiiImage视图
。测试应用程序构建得很好,没有任何问题,但当我按下“选择照片”或“拍摄照片”按钮时,应用程序崩溃。这仅仅是因为模拟器在技术上既没有相机也没有照片库可供选择吗?这就是它给我的错误:UIStatusBarStyleBlackTranslucent
在此设备上不可用
Cameratest[8290:11303]***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因是:“在iPad上,必须通过UIPopoverController显示UIImagePickerController
非常感谢您的建议 来自苹果:
硬件模拟支持
iOS模拟器不模拟加速计或摄像头硬件
此外,H2CO3是正确的,您遇到了另一个问题,错误消息非常清楚:
'在iPad上,UIIMagePickerController必须通过UIPopoverController显示'
快速的谷歌搜索将我指向了下面的链接。看看祖贝尔的回答。我认为在iPad上运行时,您需要在popover中展示UIImagePickerController
来自苹果:
硬件模拟支持
iOS模拟器不模拟加速计或摄像头硬件
此外,H2CO3是正确的,您遇到了另一个问题,错误消息非常清楚:
'在iPad上,UIIMagePickerController必须通过UIPopoverController显示'
快速的谷歌搜索将我指向了下面的链接。看看祖贝尔的回答。我认为在iPad上运行时,您需要在popover中展示UIImagePickerController
没有模拟器不支持模拟摄像机。对于摄像头,您必须在设备上运行应用程序没有模拟器不支持模拟摄像头。对于摄像头,您必须在设备上运行应用程序不,不需要,但错误甚至不是这个。尝试阅读并理解错误消息。不,它没有,但错误甚至不是这个。请尝试阅读并理解错误消息。谢谢,我刚刚用谷歌搜索了UIPopoverController,找到了一个有效的解决方案。但是,是的,相机仍然是一个不允许的,所以谢谢你提供的链接!谢谢,我刚刚用谷歌搜索了UIPopoverController,找到了一个有效的解决方案。但是,是的,相机仍然是一个不允许的,所以谢谢你提供的链接!
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize imageView,choosePhoto,takePhoto;
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(IBAction)getPhoto:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentViewController:picker animated:YES completion:nil];
}
-(IBAction)takePhoto:(id)sender {
UIImagePickerController *picker2 = [[UIImagePickerController alloc] init];
picker2.delegate = self;
picker2.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker2 animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
-(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end