I wrote a code that gives each cell a number starting from 8 in my table, this app is in hours
- (UITableViewCell *) TableView: (UITableView *) Table View CellForouaitindPath: (NSIndexPath *) indexPath {static NSString * CellIdentifier = @ "cell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: For CellEdentifierIndexPath: indexPath]; While (hour and lieutenant; 15) {if (hour == 12) {hour = 1; } And {NSString * str = [NSString stringWithFormat: @ "% d", hour]; Cell.textLabel.text = [Course objectAtIndex: indexPath.row]; Cell.detailTextLabel.text = str; NSLog (@ "% @", str); Hours ++; Return cell; }} Return cell;} When I run the app with the simulator, but when I scroll, the number changes in the first and second cells and I want to add numbers Do not change even if I scroll to the table.
How can I do this? thank you in advanced.
It seems that the hour is defined outside the method and < Code> indexPath . If you want to make sure that the displayed string remains constant for one cell, then you should definitely be able to calculate it from indexPath , thus far If the table exits cells out of order, they should keep their correct text.
No comments:
Post a Comment