Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen selecting a cell in my UITableView, the selection is seemingly random
    primarykey
    data
    text
    <p>I have a UITableView I create programatically, along with the cells, that displays a list of fonts the user can choose from to change the font they read with. Upon tapping a cell in the tableview, however, the font family sent back with the delegate is not the font that is displayed in the cell. One minute tapping "Times New Roman" will change it to Helvetica, and the next it will change it to Baskerville.</p> <p>Here's the relevant code:</p> <pre><code>- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { // Depending on which row (font) they selected, use the delegate to change the // reading text to that font switch (indexPath.row) { case 0: [self.delegate changeFontTo:@"Helvetica"]; break; case 1: [self.delegate changeFontTo:@"Times New Roman"]; break; case 2: [self.delegate changeFontTo:@"Baskerville"]; break; case 3: [self.delegate changeFontTo:@"OpenDyslexic"]; break; } } </code></pre> <p>And the delegate method:</p> <pre><code>- (void)changeFontTo:(NSString *)fontFamily { self.textToReadLabel.font = [UIFont fontWithName:fontFamily size:self.textToReadLabel.font.pointSize]; } </code></pre> <p>And if it helps, here is the UITableView delegate method for the creation of the rows:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"FontCell"; FontCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; int row = indexPath.row; cell.selectionStyle = UITableViewCellSelectionStyleBlue; cell.fontFamilyLabel.text = self.fonts[row]; if ([self.fonts[row] isEqualToString:@"Helvetica"]) { cell.fontFamilyLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0]; } else if ([self.fonts[row] isEqualToString:@"Times New Roman"]) { cell.fontFamilyLabel.font = [UIFont fontWithName:@"Times New Roman" size:17.0]; } else if ([self.fonts[row] isEqualToString:@"Baskerville"]) { cell.fontFamilyLabel.font = [UIFont fontWithName:@"Baskerville" size:17.0]; } else if ([self.fonts[row] isEqualToString:@"Dyslexic"]) { cell.fontFamilyLabel.font = [UIFont fontWithName:@"OpenDyslexic" size:17.0]; } return cell; } </code></pre> <p>Really confused as to what it could be. I've muddled and muddled with the code, but I feel like it might be just a concept I don't understand that's causing the issue.</p>
    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