[Solved] Having problems using a custom cell instead the default cell [closed]


The only thing you ned in your table view controller is this:

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerNib:[UINib nibWithNibName:@"CellCustomLoadCell" bundle:nil] forCellReuseIdentifier:@"CellCustomLoadCell"];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"CellCustomLoadCell";
    CellCustomLoadCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    cell.loadNumber.text=@"rodrigo";
    return cell;
}

Registering the nib, outside the cellForRowAtIndexPath method is the new way to use a nib based cell.

You also have a problem in the ViewController class, on how you get the table view controller on screen. You shouldn’t just add its view as a subview of your view. You could use a push or do a modal presentation to move to the next controller, or just change the root view controller of the window, like this (this code is in your ViewController class, and I’ve commented out the line where you add the subview):

- (IBAction)login:(id)sender {
    RodrigoTableViewController *test = [[RodrigoTableViewController alloc] initWithNibName:@"RodrigoTableViewController" bundle:nil];
    //[self.view addSubview:test.view];

    self.view.window.rootViewController = test;
}

7

solved Having problems using a custom cell instead the default cell [closed]