On 20 Feb 2012, at 12:46 PM, Vavelin Kevin wrote: I try to make a segue for each row in my TableView that i manage with an identifier. And i'm just blocked right now. I have one row on my storyboard, i fill my tableView with this method :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:MyIdentifier]; // Configuration de la cellule NSString *cellValue = [laboratoire objectAtIndex:indexPath.row]; cell.textLabel.text = cellValue; return cell; }
And the problem is i don't know how can i manage my application for each row have a view, do i add more row on storyboard and define it on my masterViewController.m ?
If you're using prototype cells in a storyboard, dequeueReusableCellWithIdentifier: will never return nil, so long as there is a prototype cell with that identifier in the table's scene. Every time you call that method, it will create a new instance of that prototype cell (or take one from cache). If you have only one kind of cell, just call dequeue…, don't bother alloc/initing a cell, and you'll be fine.
If you have more than one prototype in the storyboard, they should have different identifiers. (And, of course, different layouts, because there is no sense in two prototypes for the same kind of cell.) Your cellForRow… method should figure out which kind of cell should be displayed in that row, select the corresponding identifier, dequeue…, and set the content as needed.
— F
|