iphone - implement prototype cell when I click a button in another view Controller -
my program has 1 view controller , tableview controller. intend upgrade tableview cell current time everytime click button in viewcontroller.
viewcontroller.m
@interface viewcontroller () @property(nonatomic,strong) brain* brain; @property(nonatomic,readonly)timetablecontroller* tablecontrol; @end - (void)viewdidload { [super viewdidload]; _brain=[[brain alloc] init]; _tablecontrol=[[timetablecontroller alloc] init]; } - (ibaction)actiontime:(id)sender { [self.tablecontrol.entrytime addobject:[self.brain currenttime]]; }
timetablecontroller.h
@property (strong, nonatomic) iboutlet uitableview *timetable; @property(nonatomic,strong) nsmutablearray* entrytime;
timetablecontroller.m
- (void)viewdidload { [super viewdidload]; _entrytime=[[nsmutablearray alloc] init]; _timetable=[[uitableview alloc] init]; #pragma mark - table view data source - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { if(!_entrytime) return 0; else return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [_entrytime count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { ... self.cell.timelabel.text = [nsstring stringwithformat:@"%@",[self.entrytime objectatindex:[indexpath row]]]; } [self.tablecontrol.timetable reloaddata]; return cell; }
however, when press button, nothing happens. can me solve it?
where
@property(nonatomic,strong) nsstring* timelabel;
?
then dont forget connect in xib file after placing label in custom cell located in xib file.
Comments
Post a Comment