iphone如何根据base sdk版本确定并编码?
我有一个 UIImage 选择器的代码
photoImagePicker=[[UIImagePickerController alloc]init];
photoImagePicker.delegate=self;
photoImagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
photoImagePicker.mediaTypes=[UIImagePickerController availableMediaTypesForSourceType:photoImagePicker.sourceType];
[self presentModalViewController:photoImagePicker animated:YES];
photoImagePicker.showsCameraControls = YES; //Doesnot work on 3.0
photoImagePicker.navigationBarHidden = YES;
photoImagePicker.toolbarHidden = YES;
photoImagePicker.allowsEditing=YES; //Doesnt work on 3.0
现在,当 sdk 为 3.1 或更高版本时,一切正常,但当我将操作系统版本设置为 3.0 时,代码开始显示错误。结果这些方法在 3.0 中不存在,因此出现错误。我想保留一种机制,使这些能够适用于更高版本(3.1),同时适用于 3.0 版本。 我该怎么做?
我想到的一种解决方案是验证版本值,然后输入该代码。但我不确定这是怎么得到的。任何帮助将不胜感激。
I have a code for UIImage picker
photoImagePicker=[[UIImagePickerController alloc]init];
photoImagePicker.delegate=self;
photoImagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
photoImagePicker.mediaTypes=[UIImagePickerController availableMediaTypesForSourceType:photoImagePicker.sourceType];
[self presentModalViewController:photoImagePicker animated:YES];
photoImagePicker.showsCameraControls = YES; //Doesnot work on 3.0
photoImagePicker.navigationBarHidden = YES;
photoImagePicker.toolbarHidden = YES;
photoImagePicker.allowsEditing=YES; //Doesnt work on 3.0
Now everything works fine when the sdk is 3.1 or higher but when i put the os version as 3.0, the code starts showing errors. Turns out these methods were not present in 3.0 and so errors. I want to keep a mechanism which will enable these for higher versions(3.1) and at the same time work properly for 3.0 version.
How do i do it?
One solution i have thought of is to verify the version value and then put that code. But i am not sure how this is got. Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你应该能够使用 来做到这一点弱链接。本文如何构建单个 iPhone 应用程序支持同时使用 2.x 和 3.0 也应该会有所帮助。
I think you should be able to do it using Weak Linking. This article How to build a single iPhone application support both 2.x and 3.0 at the same time should also help.