J'ai UITableViewController
dans mon storyboard
dans lequel il y a trois cellules avec sur l'étiquette au milieu sur chacun. Par exemple, si un utilisateur clique sur la première étiquette de la cellule en afficher une autre tableview
avec la liste des éléments en sélectionnant un élément, il revient au précédent tableView
et le nom de l'élément doit être imprimé à la place de l'étiquette.Initialiser UITalbleViewController dans le code
#import <UIKit/UIKit.h>
@interface carSelectCellTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *carMake;
@property (weak, nonatomic) IBOutlet UILabel *carModel;
@property (weak, nonatomic) IBOutlet UILabel *carRego;
@property (weak, nonatomic) IBOutlet UILabel *carYear;
//the below label are the labels in the cells.
@property (weak, nonatomic) IBOutlet UILabel *carSelected;
@property (weak, nonatomic) IBOutlet UILabel *location;
@property (weak, nonatomic) IBOutlet UILabel *service;
@end
#import "BookService.h"
#import <Parse/Parse.h>
#import "carSelectCellTableViewCell.h"
@interface BookService()
@end
@implementation BookService
@synthesize tableView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableView.delegate = self;
self.tableView.dataSource = self;
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cell tabbed");
PFObject *temp = [customerCars objectAtIndex:indexPath.row];
NSLog(@"%@", temp.objectId);
NSString *car = temp.objectId;
UIStoryboard *dashboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *change = [dashboard instantiateViewControllerWithIdentifier:@"bookAservice"];
[self presentViewController:change animated:YES completion:nil];
static NSString *Identifier = @"carSelectedCell";
//here is where i'm calling the cell to change the label value when the selection is made. before dequeueReusableCellWithIdentifier there should be appropriate tableView Table.
carSelectCellTableViewCell *cell2 = [dequeueReusableCellWithIdentifier:Identifier];
cell2.carSelected.text = @"selcted";
}
Comment est-ce que je peux initier le tableauView par programmation. Alors que je peux changer la valeur de l'étiquette de la cellule à l'élément sélectionné.