iphone如何根据base sdk版本确定并编码?

发布于 2024-09-05 20:37:54 字数 790 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心激荡 2024-09-12 20:37:54

我认为你应该能够使用 来做到这一点弱链接。本文如何构建单个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文