Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding custom button in tableview with tag
    primarykey
    data
    text
    <p>Hello everyone, I am trying to add custom button with tag related to indexPath.row. I can view the tag value correctly if I don't insert new row into tableview. But, when I insert new row, my tag value of new row is not correct if the inserted row is not within 0 to 9 (iphone 5 can show up to that). On iphone, I need to scroll down to see. <br><br> <br> However, with the same code, I can get my tag value correctly on my ipad. I don't need to scroll down table view on my ipad to see all my row.I would like to know why it happen and how to solve.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"dialoguesTableCell"; dialoguesCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[dialoguesCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeCustom]; [yourButton setImage:[UIImage imageNamed:@"1StarBlank.png"] forState:UIControlStateNormal]; [yourButton setTitle:@"Button" forState:UIControlStateNormal]; [yourButton addTarget:self action:@selector(buttonSelected:) forControlEvents:UIControlEventTouchUpInside]; yourButton.tag=indexPath.row; yourButton.frame = CGRectMake(5, 10, 40, 25); [cell addSubview:yourButton]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSIndexPath *indexPathstoinsert = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:section]; NSArray *indexPathsToInsertArray = [NSArray arrayWithObject:indexPathstoinsert]; [[self mainTableView] insertRowsAtIndexPaths:indexPathsToInsertArray withRowAnimation:UITableViewRowAnimationRight]; } </code></pre>
    singulars
    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