ios - drawing image in cameraOverlayView -


i'm using code create uiimagepickercontroller custom cameraoverlayview. testing purposes, overlay's supposed circle draw in circleview using uibezierpath. however, circle drawn in circleview not appearing in overlay. overlay supposed subclass of uiview circleview is. can explain why circle not appearing when overlay pops up? initialize circleview in viewdidload , set cameraoverlayview in viewdidappear.

viewcontroller

@property (strong, nonatomic) circleview *overlay; 

viewdidload

self.overlay = [[circleview alloc] init]; 

viewdidappear

    if ([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {          uiimagepickercontroller *picker = [[uiimagepickercontroller alloc] init];          picker.delegate = self;         picker.allowsediting = yes;         picker.sourcetype = uiimagepickercontrollersourcetypecamera;         picker.showscameracontrols = no;         picker.navigationbarhidden = yes;         picker.wantsfullscreenlayout = yes;         picker.cameraoverlayview = self.overlay;         picker.mediatypes = [[nsarray alloc] initwithobjects: (nsstring *) kuttypemovie, nil];          [self presentviewcontroller:picker animated:yes completion:null];     } 

circleview

- (id)initwithcoder:(nscoder *)adecoder {      if (self = [super initwithcoder:adecoder]) {          self.shape = [uibezierpath bezierpathwithovalinrect:(cgrectmake(0, 50, 50, 50))];       }     return self; }   - (void)drawrect:(cgrect)rect{    [[uicolor colorwithred: (114/255.0) green: (5/255.0) blue:(46/255.0) alpha:1] setfill];    [self.shape fill];   } 

there 2 problems here:

  • your circle overlay view has 0 size, because create init instead of initwithframe: (init falls on frame of {0,0,0,0}, because have provided no frame information).

  • your circle overlay view important initialization in initwithcoder:, method never called, since instantiating init instead. self.shape nil , nothing drawn in drawrect:.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -