xcode - How to run presentViewController in IOS static library -
i trying build static library camera in ios, showing error in user application
attempt present <uiimagepickercontroller: 0x17e2f740> on <camera: 0x17d3f5b0> view not in window hierarchy!
i using code in camera.m inside static library libcamera.a
-(void)callcamera { uiimagepickercontroller * picker = [[uiimagepickercontroller alloc] init]; picker.delegate = self; picker.sourcetype = uiimagepickercontrollersourcetypecamera; [self presentviewcontroller:picker animated:yes];// error line }
i using library in application checkcamera.m importing libcamera.a
-(void)viewdidload { [super viewdidload] camera cam=[[camera alloc]init]; [cam callcamera] }
but showing above mentioned error, want know how run presentviewcontroller inside static library?
try move [cam callcamera]
viewdidload
viewdidappear
. according uiviewcontroller class reference viewdidappear
exact method indicates view controller's view added window hierarchy.
edited:
if camera
subclass of uiviewcontroller
, please try this:
- (void)viewdidappear:(bool)animated { [super viewdidappear:animated]; camera *cam=[[camera alloc] init]; [self.view addsubview:cam.view]; [self addchildviewcontroller:cam]; [cam callcamera]; }
Comments
Post a Comment