iphone: Adding UIRequiredDeviceCapabilitie
I am reading the "Device Support - Setting Required Hardware Capabilities" on http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedFeatures/AdvancedFeatures.html
I want to add still-camera capability by doing the following:
- Open my Info.plist
- Click +
- Add UIRequiredDeviceCapabilities on the Key column
- Add still-camera on the Value column
- Save the updated Info.plist
Is this the correct way?
Thanks in advance for your hel开发者_如何学JAVAp.
If you only want to have the capability to utilize the still camera, you don't have to do anything, except check that the camera exists at runtime:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//Something
}
This is the correct approach, if your application has utility, even when run on a device without a camera. If, on the other hand, your App needs the camera in order to function, then changing the plist is the correct approach, as this is a signal to Apple that your App can not be used on a device without a camera. In that case the procedure you outlined is correct.
Someone at the Developer Forum answered my question.
At the Raw Values/Keys mode
- Click + sign to add a row
- Enter UIRequiredDeviceCapabilities
- XCode recognizes the key and automatically creates an item 0
At the "friendly" (Uncheck Raw Values/Keys) mode
- Type "Required device capabilities"
- XCode recognizes it and will auto-complete it
You don't necessarily need to set up UIRequiredDeviceCapabilities as a dictionary. It can also be an array. You use a dictionary if some of your options need to be YES and some need to be NO. If you're just trying to set capabilities you require, using an array can be a little simpler.
See "UIRequiredDeviceCapabilities " at https://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
精彩评论