user interface - iOS: UITableView in popover and seeing "double vision" effect -


i'm working on ipad app , @ points, need show popover options user pick from. this, use uitableview in uipopovercontroller. problem that, on ipad (not on simulator), when scrolling tableview, sort of "double vision" effect, appears 2 sets of of list exist. 1 stationary, , 1 scrolls , down.

i construct popover this:

self.fclasstypelist = [[nsmutablearray alloc] init]; [self.fclasstypelist removeallobjects];  nsuinteger stringlength = 0; (populate self.fclasstypelist, , set stringlength size of longest entry)  [self setcontentsizeforviewinpopover:cgsizemake(stringlength * 15.0f, [self.fclasstypelist count] * 30)];  cgfloat tableborderleft = 5; cgfloat tableborderright = 5; cgrect viewframe = self.view.frame; viewframe.size.width -= tableborderleft + tableborderright; // reduce width of table  self.flistofitems = [[uitableview alloc] initwithframe:viewframe style:uitableviewstyleplain]; self.flistofitems.delegate = self; self.flistofitems.datasource = self; [self.view addsubview:self.flistofitems]; 

i put in viewdidlayoutsubviews(…) part of view controller, maybe should put somewhere else? not sure why happens on actual machine, not simulator.

-viewdidlayoutsubviews weird place put allocations because method can called multiple times. far main issue goes, believe should move allocations -init method, , move layout code -viewwillappear method.

- (id)init {     self = [super init];     if (self)     {         self.fclasstypelist = [[nsmutablearray alloc] init];          self.flistofitems = [[uitableview alloc] initwithframe:cgrectzero style:uitableviewstyleplain];         self.flistofitems.delegate = self;         self.flistofitems.datasource = self;         [self.view addsubview:self.flistofitems];     }      return self; }  - (void )viewwillappear:(bool)animated {     [super viewwillappear:animated];      nsuinteger stringlength = 0;      cgfloat tableborderleft = 5;     cgfloat tableborderright = 5;     cgrect viewframe = self.view.frame;     viewframe.size.width -= tableborderleft + tableborderright; // reduce width of table     self.flistofitems.frame = viewframe;      [self setcontentsizeforviewinpopover:cgsizemake(stringlength * 15.0f, [self.fclasstypelist count] * 30)]; } 

this promotes better memory management.

as added bonus, recommend refactor [self setcontentsizeforviewinpopover:cgsizemake(stringlength * 15.0f, [self.fclasstypelist count] * 30)]; method setter method of fclasstypelist. better call -viewwillappear: in same setter method instead. promote scalability (or else) continues build upon code later on.

it's little confusing see you're trying accomplish in code because it's hardcoded let me know if i'm missing mark you're looking (w/ explanation why) , i'll make edit.

cheers


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -