In my application I have the option for a torch light. Howevver, only iPhone 4 and iPhone 4S have torch lights. Other devices do not have the torch light. How can I find the current device model? Please help me. Thanks in advance.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- laravel create model from custom stub when using p
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
devicesWithMediaType:
is now deprecated.Swift 4:
Swift 4
Swift 4
This code will give your device the ability to turn on the flashlight. But it will also detect if the flashlight is on or off and do the opposite.
}
You should not use the device model as an indicator of whether a feature is present. Instead, use the API that tells you exactly if the feature is present.
In your case, you want to use
AVCaptureDevice
's-hasTorch
property:More information is available in the AV Foundation Programming Guide and the AVCaptureDevice Class Reference
You can have less code and use less memory than the code above:
hasTorch will now contains the correct value