My program has one view controller and a tableView controller. I intend to upgrade my tableview cell with the current time everyTime I click a 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 I press the button, nothing happens. Can someone help me to solve it?
Where is your
@property(nonatomic,strong) NSString* timeLabel;
?
Then dont forget to connect that in your xib file after placing a label in your custom cell that is located in the xib file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.