Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve data from UITableview form
    primarykey
    data
    text
    <p>I am building a booking app, and here is the UI looks like:</p> <p><img src="https://i.stack.imgur.com/i04cL.png" alt="Booking form"></p> <p>Here is my code:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *identifier; switch (indexPath.row) { case 0: identifier=@"noTextField"; break; case 1: identifier=@"withTextField"; break; case 2: identifier=@"withTextField"; break; case 3: identifier=@"noTextField"; break; case 4: identifier=@"withTextField"; break; case 5: identifier=@"withTextField"; break; default: break; } TitleCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath]; switch (indexPath.row) { case 0: cell.leftLabel.text = @"Title"; cell.rightLabel.text = @"Mr"; cell.rightLabel.textAlignment=NSTextAlignmentRight; break; case 1: cell.leftLabel.text = @"FirstName"; cell.textField.placeholder=@"e.g. John"; break; case 2: cell.leftLabel.text = @"LastName"; cell.textField.placeholder=@"e.g. Doe"; break; case 3: cell.leftLabel.text = @"Birthdate"; [cell.leftLabel sizeToFit]; cell.rightLabel.text = @"Sun, 17 Nov 2013"; cell.rightLabel.textAlignment=NSTextAlignmentRight; //[cell.rightLabel sizeToFit]; break; case 4: cell.leftLabel.text = @"Nationality"; cell.textField.placeholder=@"e.g. Indonesia"; break; case 5: cell.leftLabel.text = @"ID Number"; cell.textField.placeholder=@"e.g. 1234567890"; break; default: break; } return cell; } </code></pre> <p>I am stuck on two problems:</p> <ul> <li>The <code>dequeueReusableCellWithIdentifier</code> seems to be replacing the same identifier cell, so after scrolling some of the <code>UITextField</code> will already have a data inside. How do I overcome that? Is it possible to deactivate the <code>dequeueReusableCellWithIdentifier</code>?</li> <li>How do I retrieve the data inside from each sections and cell? I am using a storyboard.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload