UITableView Lags Due a Particular Object -


in home page of app, have icarousel object scrolls images. under there uitableview - table view problem is.

lately added sevenswitch object each cell in table view , since scrolling lags lot! code added in tableview:cellforrowatindexpath: method:

cella.subscribed = [[sevenswitch alloc] initwithframe:cgrectmake(cella.frame.size.width-60, cella.frame.size.height / 2 - 12, 50, 25)]; cella.subscribed.offimage = [uiimage imagenamed:@"off.png"]; cella.subscribed.onimage = [uiimage imagenamed:@"on.png"]; cella.subscribed.thumbtintcolor = [uicolor colorwithred:(230/255.0) green:(230/255.0) blue:(230/255.0) alpha:1]; cella.subscribed.activecolor = [uicolor colorwithred:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:1]; cella.subscribed.inactivecolor = [uicolor colorwithred:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:1]; cella.subscribed.ontintcolor = [uicolor colorwithred:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:1]; cella.subscribed.isrounded = no; cella.subscribed.tag = [[tempcat objectforkey:@"id"] intvalue];  [cella.subscribed addtarget:self action:@selector(changesinglecategory:) forcontrolevents:uicontroleventvaluechanged];  if ([[tempcat objectforkey:@"subscribed"] isequaltostring:@"y"]) {     cella.subscribed.on = yes; } else {     cella.subscribed.on = no; }  [cella.contentview addsubview:cella.subscribed]; 

is there way create custom object without setting properties everytime?

the whole point of cells in table views reused. should not apply cell, content (subviews).

you must have cell subclass should put switch creation , configuration code class (and add subview there). now, each time create / dequeue cell have switch (and reused 99% of time) , need call cella.subscribed.on = ... appropriate setting.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -