iphone - how to change cell background color or image on click in ipad -


i want try ,when click on cell color should change , color should stay on cell clicked.till here success in .but when table refresh cell background color disappear wrong please me on got code apple document use .i miss line in code

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      static nsstring *cellidentifier = @"cell";      uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil) {         cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];        //here create view color cell when cell click view should display background write or wrong doing please me here why view disappear when tableview refresh view disapper cell want stay place till user not click other cell&mt tableview grouped tableview.        uiview *v = [[[uiview alloc] init] autorelease];        v.layer.cornerradius =6.0f;        v.backgroundcolor = [uicolor darkgraycolor];        cell.selectedbackgroundview = v;        }      return cell; }    - (void)tableview:(uitableview *)tableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath {     if (indexpath.row == 0 || indexpath.row%1 == 0) {         uicolor *altcellcolor = [uicolor colorwithwhite:0.2 alpha:0.1];         cell.backgroundcolor = altcellcolor;      }   } 

if want retained selected row on refresh can save selected indexpath , use following method:

nsindexpath *rowtoselect; //save selected indexpath  [mytableview selectrowatindexpath:rowtoselect animated:yes scrollposition:uitableviewscrollpositionnone; [mytableview scrolltorowatindexpath:rowtoselect atscrollposition:uitableviewscrollpositionnon animate:yes]; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -