ios - Changing cell content in UITableView when tapped -


i'm building app has table view. want table view expands cell when tap on , close when tap second time.

but wondering if following possible. when cell isn't selected see picture, title , beginning of text. cell selected, expand , show more subviews, i.e. image views.

is possible? instance, hide subview in cell, , tapped it's visible , aligned right way? , of course, how do that?

thnx!!!

i did similar quite few time ago. you'll find code @ github.

note rough, beginning iphone days, i.e. properties missing.

.h

#import <uikit/uikit.h>   @interface firstviewcontroller : uitableviewcontroller <uitableviewdelegate, uitableviewdatasource> {     nsindexpath *selectedindexpath;     nsdictionary *articles; }  @end 

.m

#import "firstviewcontroller.h" @implementation firstviewcontroller - (void)viewdidload {     [super viewdidload];     selectedindexpath = nil;     articles = [[nsdictionary dictionarywithobject:[nsarray arraywithobjects:@"one", @"two", @"three",                                                     @"four", @"five", @"six",                                                     @"seven", @"eight", @"nine",                                                     @"ten", @"eleven", nil]                  forkey:@"title"] retain]; } - (void)didreceivememorywarning {     // releases view if doesn't have superview.     [super didreceivememorywarning];     // release cached data, images, etc aren't in use. } - (void)viewdidunload {     // release retained subviews of main view.     // e.g. self.myoutlet = nil; } - (void)dealloc {     [selectedindexpath release];     [articles release];     [super dealloc]; }  - (int)numberofsectionsintableview:(uitableview *)tableview {     return [[articles allkeys] count]; }  - (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section {     return [[articles allkeys] objectatindex : section]; }  - (int)tableview:(uitableview *)table numberofrowsinsection:(nsinteger)section {     id key = [[articles allkeys] objectatindex:section];     return [[articles objectforkey : key] count]; }  - (float)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     if ((selectedindexpath != nil) && (selectedindexpath.row == indexpath.row))         return 80.0;     return 40.0; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring * myidentifier = @"myidentifier";     uitableviewcell * cell = [self.tableview dequeuereusablecellwithidentifier:myidentifier];     if (cell == nil) {         cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:myidentifier] autorelease];     }     id key = [[articles allkeys] objectatindex:indexpath.section];     cell.textlabel.text = [[articles objectforkey:key] objectatindex:indexpath.row];     return cell; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     if (selectedindexpath == indexpath) {         selectedindexpath = nil;     } else {         selectedindexpath = indexpath;     }     [self.tableview deselectrowatindexpath : indexpath animated : no];     [tableview beginupdates];     [tableview endupdates]; }  @end 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -