• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dynamic Prototype Cell and Segues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic Prototype Cell and Segues


  • Subject: Re: Dynamic Prototype Cell and Segues
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 22 Feb 2012 16:52:31 -0600


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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Dynamic Prototype Cell and Segues (From: Vavelin Kevin <email@hidden>)

  • Prev by Date: Couldn't register com.me.myapp with the bootstrap server
  • Next by Date: Re: 4.3 question and old Developer folder
  • Previous by thread: Dynamic Prototype Cell and Segues
  • Next by thread: Open multiple files to separate windows?
  • Index(es):
    • Date
    • Thread