Open camera in UIActionSheet

Discussion in 'iOS Programming' started by aceiswild, Nov 18, 2011.

  1. aceiswild macrumors newbie

    Joined:
    Nov 15, 2011
    Location:
    Canada
    #1
    Hey guys, so I have a button that opens an AlertView. In the alert view there is an option button to Choose New Photo. When you click Choose New Photo, it opens a UIActionSheet which show 2 options "Take a new picture" and "Choose from gallery".
    When i click Take a new picture it opens the camera fine but will not allow me to take a picture.
    (If i open the camera with a button straight from an alert view, the camera opens fine and take a picture. It just won't work to take a picture in UIActionSheet).

    Any suggestions why this could happen?

    Thanks in advance,
    Steve
     
  2. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #2
    My guess would be that you are not dismissing/releasing the actionsheet when your selection is made, however, all anyone can do is guess when no actual code is provided.
     
  3. aceiswild thread starter macrumors newbie

    Joined:
    Nov 15, 2011
    Location:
    Canada
    #3
    sorry, here is my .M file where all the main code is.
    I have everything labeled in green so it sorts everything out.

    here is the link: http://www.mediafire.com/file/rwwb81c5cufrbjf/SliderController.m

    Again, When you click New Game in the Alert View it opens a UIActionSheet which then you can take a new picture or choose from gallery. When taking a new picture i can open the camera but not take a picture.

    Let me know if you need more information!

    Thanks,
    Steve
     
  4. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #4
    Hmm. I'm not at my computer to test any of this (that's my disclaimer ;) ) but the line after you show the instance of the Alertview you should release it since the void method with the dismiss statement is commented out near the end. I wonder if the problem is happening when you call the actionsheet from the alertview? Are you able to get the camera working from the actionsheet via viewDidLoad (bypassing the alertview)? You could also try dismissing the actionview onclick like the alertview method which is commented out. It also seems funny that your picker is presented and then dismissed in the very next line. Perhaps the intent is to dismiss after an action occurs.

    Good luck,
    Nick
     
  5. aceiswild, Nov 18, 2011
    Last edited: Nov 18, 2011

    aceiswild thread starter macrumors newbie

    Joined:
    Nov 15, 2011
    Location:
    Canada
    #5
    Thanks nick,
    I have release a bunch of things since i last posted my code to you.
    It would not allow me to use ViewDidLoad with ViewDidAppear. Or else i would get an error message but the application would still run. So I commented out the ViewDidLoad and used ViewDidAppear which fixed that error.

    The Camera will open in the action sheet but will not take a picture. If i open the camera in an alert view it will show fine and take a picture but will not dismiss!!! Its kind of weird. I could get the camera to load automatically by using ViewDidLoad but it should show my menu first.
    If you want i can zip my project up and you could see if i have all my releases.
    Im not looking for somebody to do my project, but hell, I've been having a headache with this for the past week!! So any help is very much appreciated!
    If you do end up testing my puzzle at anytime just shake the phone to get back to the main menu. Also, please please don't steal my project like somebody did with my last one and i could not submit it!!
    It would have to be tested on a device to activate the camera.

    Thank you,
    Steve
     
  6. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #6
    Wirelessly posted (Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5)

    Work backwards. Try to get the camera to take pictures at the view's launch and then incorporate that code into your project. It probably has something to do with the camera delegate not being set up properly for dismissal. Fix that first.
     

Share This Page