cocoa touch - UIImagePickerControllerSourceTypeCamera crashes in IPHONE Simulator? -


is known issue if try test uiimagepickercontroller using camera source type simulator crash?

i have following code:

self.imgpicker = [[uiimagepickercontroller alloc] init]; self.imgpicker.allowsediting = no; self.imgpicker.delegate = self; [self.imgpicker setsourcetype:uiimagepickercontrollersourcetypecamera]; [self presentmodalviewcontroller:self.imgpicker animated:yes]; [imgpicker release]; 

running in simulator, objc-exception-throw error on stack @ -[uiimagepickercontroller setsourcetype:].

now if set source type photo library though, runs smoothly , fine? what's deal?

simulator doesn't have camera , can't simulate take picture (it have been nice use isight apple has not been kindly). code not safe because, example, old ipod touch doesn't have camera , in case app crash on device.

as apple suggest in uiimagepickercontroller documentation:

to use image picker controller containing default controls, perform these steps:

1.verify device capable of picking content desired source. calling issourcetypeavailable: class method, providing constant “uiimagepickercontrollersourcetype” enum.

2.check media types available, source type you’re using, calling availablemediatypesforsourcetype: class method. lets distinguish between camera can used video recording , 1 can used still images.

3.tell image picker controller adjust ui according media types want make available—still images, movies, or both—by setting mediatypes property.

4.present user interface calling presentmodalviewcontroller:animated: method of active view controller, passing configured image picker controller new view controller.

5.when user taps button pick newly-captured or saved image or movie, or cancels operation, dismiss image picker using delegate object. newly-captured media, delegate can save camera roll on device. previously-saved media, delegate can use image data according purpose of app.

so have call issourcetypeavailable , set sourcetype consistently.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -