hey guys... need here...really cant find in google...
i have tabbed app, in 1 of thos tabs show uiimagepickercontroller picture camera... use overlay view, when camera take 3 seconds "open" "irs" (starting animation), overlay view visible, on closed iris!!!
i need check how test if iris still close, can hidde overlay view.
i read posts subclassing uiimagepickercontroller, apple said should not wifh uiimagepickercontroller....
any 1 has clue? lost here....
thx
the iris animation fires on [uiimagepickercontroller viewdidappear]
method. apple discourages subclassing uiimagepickercontroller variety of reasons, if need add overlay after iris animation finishes , not willing write own image capture class avfoundation, this:
if don't have one, add new subclass of uitabbarviewcontroller
uiimagepickercontroller @property
, delegates uiimagepickercontrollerdelegate
, uinavigationcontrollerdelegate
@interface my_tabbarviewcontroller : uitabbarcontroller <uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate> @property (nonatomic, strong) uiimagepickercontroller *picker;
in implementation, add initcamera
method , call in viewdidload
- (void)initcamera { _picker = [[uiimagepickercontroller alloc] init]; _picker.sourcetype = uiimagepickercontrollersourcetypecamera; _picker.view.frame = cgrectmake(0.f, 20.f, 320.f, 499.f); _picker.navigationbarhidden = true; _picker.delegate = self; _picker.cameraoverlayview = yourcameraoverlayview; [self.view addsubview:_picker.view]; [_picker viewdidappear:false]; [self.view sendsubviewtoback:_picker.view]; }
then when camera view tab bar item tapped, show camera method on tab bar controller:
- (void)tabbar:(uitabbar *)tabbar didselectitem:(uitabbaritem *)item { nslog(@"tapped: %@", item.title); if ([item.title isequaltostring:@"camera"]) { [self.view bringsubviewtofront:_picker.view]; } else { [self.view sendsubviewtoback:_picker.view]; } }
finally, in uiimagepickercontroller
delegate method on tab bar controller, clean image picker, , send info dictionary camera view controller handle image need to:
- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { [_picker.view removefromsuperview]; yourcameraviewcontroller *camvc = (yourcameraviewcontroller*)[self.viewcontrollers objectatindex:1]; // index 1 second tab, adjust accordingly [camvc imagepickercontroller:picker didfinishpickingmediawithinfo:info]; [self initcamera]; }
the call [self initcamera];
here re-initialize uiimagepickercontroller
may or may not want here. #import "my_tabbarviewcontroller.h
in yourcameraviewcontroller
, grab pointer picker
in uiimagepickercontroller
delegate method calling:
my_tabbarviewcontroller *tabbarvc = (my_tabbarviewcontroller*)self.tabbarcontroller;
and have yourcameraviewcontroller
dismiss , message tabbarvc
re-init uiimagepickercontroller
when need again.
Comments
Post a Comment