Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-25-2012, 04:04 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 25
veterinarian2008 is on a distinguished road
Default Detecting if device has LED light or Flash

Hello guys!

I am trying to find a way to detect if the device has the LED light functionality. I know how to know if the camera has a camera but the LED light I don't. I have been researching some and I have not find anything really helpful. Anyways, so I just want to show and alert using a if statement if the device has no LED light.

How can I do this? I have looked at the API's and Docs but I don't understand how to actually get in in a code...

Thank you.
veterinarian2008 is offline   Reply With Quote
Old 01-25-2012, 04:45 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Loading… > hasTorch
baja_yu is offline   Reply With Quote
Old 01-25-2012, 05:06 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 25
veterinarian2008 is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Loading… > hasTorch
okay, so I did this:

Code:
if ([captureDevice hasTorch] && [captureDevice hasFlash]) {

	MainViewController *screen = [[MainViewController alloc] initWithNibName:nil bundle:nil];
     screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:screen animated:YES];
	[screen release];
        
    }
    
    else {
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No LED Light Supoorted" message:@"Your Device does not support the LED light." delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
        [alert show];
        [alert release];
        
    }

But when I try on my iPhone 4S, it just gives me the alert. why is that happening?

I think the code is fine...

thanks
veterinarian2008 is offline   Reply With Quote
Old 01-25-2012, 06:06 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 25
veterinarian2008 is on a distinguished road
Default

Anyone knows?
veterinarian2008 is offline   Reply With Quote
Old 01-25-2012, 06:31 PM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by veterinarian2008 View Post
Hello guys!

I am trying to find a way to detect if the device has the LED light functionality. I know how to know if the camera has a camera but the LED light I don't. I have been researching some and I have not find anything really helpful. Anyways, so I just want to show and alert using a if statement if the device has no LED light.

How can I do this? I have looked at the API's and Docs but I don't understand how to actually get in in a code...

Thank you.

Are you checking the back camera?

Here is the code from the Xcode docs on the subject:


Code:
AVCaptureDevice *backCamera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ( [backCamera isTorchAvailable] && [backCamera isTorchModeSupported:AVCaptureTorchModeOn]  )
{
    BOOL success = [backCamera lockForConfiguration:nil];
    if ( success )
    {
        [backCamera setTorchMode:AVCaptureTorchModeOn];
        [backCamera unlockForConfiguration];
    }
}
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 01-26-2012, 07:16 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 25
veterinarian2008 is on a distinguished road
Default

awesome!

It worked! Thank you.

I just got rid off this:

Code:
        [backCamera setTorchMode:AVCaptureTorchModeOn];
Thanks again...
veterinarian2008 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 392
11 members and 381 guests
Atatator, condor304, FrankWeller, glenn_sayers, iphonedevshani, MAMN84, mraalex, PowerGoofy, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,123
Posts: 402,908
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:53 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0