
码
UIImagePickerControllerSourceType sourceType; if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotolibrary]) { sourceType = UIImagePickerControllerSourceTypePhotolibrary; } else { sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; } //display photo library. [self startimagePickerControllerFromVIEwController: self usingDelegate: self withSourceType: sourceType];...- (BOol)startimagePickerControllerFromVIEwController:(UIVIEwController*) controller usingDelegate:(ID <UIImagePickerControllerDelegate,UINavigationControllerDelegate>) delegate withSourceType:(UIImagePickerControllerSourceType) sourceType{ //Insure camera,controller,and delegate exist. if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) return NO; //Create the ImagePicker. UIImagePickerController *imagePickerUI = [[UIImagePickerController alloc] init]; imagePickerUI.sourceType = sourceType; //Only allow still images. imagePickerUI.mediaTypes = [[NSArray alloc] initWithObjects: (Nsstring *) kUTTypeImage,nil]; //Turn off editing. imagePickerUI.allowsEditing = NO; //Set the delegate. imagePickerUI.delegate = delegate; //Present the picker vIEw. [controller presentVIEwController:imagePickerUI animated:YES completion:nil]; return YES;}解决方法 if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO)
上述条件确保模拟器无法运行它,因为模拟器没有摄像头.
总结以上是内存溢出为你收集整理的UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?全部内容,希望文章能够帮你解决UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)