How to launch iPhone Camera on viewDidLoad?

前端 未结 2 377
予麋鹿
予麋鹿 2020-12-16 07:18

I can\'t seem to launch the camera when loading my view. I end up making the user have to find and press a button on the screen just to load the camera (redundant). How can

相关标签:
2条回答
  • 2020-12-16 08:04

    You should do it in viewWillAppear:, or viewDidAppear: if the first doesn't work. trying to do it in viewDidLoad won't work because that is called after the view is first created, and the view isn't a subview of anything else at that point. As far as i understand it, in order to call presentModalViewController on self, the view must at some level be displayed in the UIWindow.

    One other thing i just noticed; your code leaks memory depending on how you declare your imgPicker property. if it is declared with retain instead of assign, then unless you explicitly release it twice somewhere that picker will always exist in memory. You should autorelease the init'd object as you assign it to the property in that case.

    0 讨论(0)
  • 2020-12-16 08:10

    Seems that it does not do it when you put the call to present modal view in view did load . You can try having a 2 second timer after the call to [super viewDidload] that pushes the picker view in or something like that.

    0 讨论(0)
提交回复
热议问题