ios - Aligning arrow with content view with custom iPad popover -


i customizing appearance of popovers subclassing uipopoverbackgroundview. working fine, except there instances there gap between arrow , content view. if keep rotating device dismiss popover bring up, line , others not. i'm logging frame sizes , consistently same, have no idea what's going on. i'm attaching screenshots , layoutsubviews code below.

where see me subtracting 4 in case of arrow direction right based on trial & error of getting work @ least of time. hate coding because i'm not sure space of 4 points , why don't need in cases of arrow direction, example.

in images 1st shot shows problem. happened on random triggering of popover. next image shows randomly working when triggered later within same execution of app.

also worth mentioning, found sample code @ http://blog.teamtreehouse.com/customizing-the-design-of-uipopovercontroller , tried version of layoutsubviews, though it's similar have. code still seeing same issue.

edit: worth mentioning might obvious screenshots not including border popover:

+ (uiedgeinsets)contentviewinsets {     return uiedgeinsetsmake(0.0f, 0.0f, 0.0f, 0.0f); } 

possibly worth mentioning not using image file arrow image rather drawing custom. again, when comment out drawing i'm still having issue, don't think it's related, wanted mention full disclosure.

any appreciated. thanks.

cgsize arrowsize = cgsizemake(kcmapopoverbackgroundviewarrowbase, kcmapopoverbackgroundviewarrowheight); // leaving code out drawarrowimage - when leave arrowimageview  // empty image view , set non-clear background color gap still  // sporadically showing self.arrowimageview.image = [self drawarrowimage:arrowsize];  float arrowxcoordinate = 0.0f; float arrowycoordinate = 0.0f; cgaffinetransform arrowrotation = cgaffinetransformidentity;  float bordermargin = 2.0f;  switch (self.arrowdirection) {     case uipopoverarrowdirectionup:         arrowxcoordinate = ((self.bounds.size.width / 2.0f) - (arrowsize.width / 2.0f));         arrowycoordinate = 0.0f;         break;      case uipopoverarrowdirectiondown:         arrowxcoordinate = ((self.bounds.size.width / 2.0f) - (arrowsize.width / 2.0f));         arrowycoordinate = self.bounds.size.height - arrowsize.height;         arrowrotation = cgaffinetransformmakerotation(m_pi);         break;      case uipopoverarrowdirectionleft:         arrowxcoordinate = 0.0f - (arrowsize.height / 2.0f) + bordermargin;         arrowycoordinate = ((self.bounds.size.height / 2.0f) - (arrowsize.height / 2.0f));         arrowrotation = cgaffinetransformmakerotation(-m_pi_2);         break;      case uipopoverarrowdirectionright:         arrowxcoordinate = self.bounds.size.width - arrowsize.height - 4.0f;         arrowycoordinate = ((self.bounds.size.height / 2.0f) - (arrowsize.height / 2.0f));         arrowrotation = cgaffinetransformmakerotation(m_pi_2);         break;      default:         break;  }  self.arrowimageview.frame = cgrectmake(arrowxcoordinate, arrowycoordinate, arrowsize.width, arrowsize.height); [self.arrowimageview settransform:arrowrotation]; 

here example of issue happening on random occurrence

this example of not happening on random occurrence on

is arrow image square? if not, i'm guessing transform affecting frame , generating unexpected gap.


Comments