Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to fetch the value from UITableViewCell by the self define methods
    primarykey
    data
    text
    <p>I am creating an app in which i have a UITableView and the table view each cell are having an UIView and the UIView contains two custom UIButton and two UILabel(all with same tag) the value of label coming from XML parsing. Now i have to do is that when i click any one button then it calls a method with the tag of the button then i want to fetch the value of the both labels of that cell and use that value.</p> <p>But when i am doing this it is not happen by calling a method i am getting the tag value but when i try to get the label value then i am unable to get.</p> <p>Is there any way to get the value of that?</p> <p>Code of the method that i am using to get the label value...</p> <pre><code>-(void)swapButtonPressed:(id)sender { NSInteger a= [sender tag]; UITableViewCell *cell; NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *) [[sender superview] superview]]; NSLog(@"%d", indexPath.row); UIView *viewForCell = (UIView *)[cell.contentView viewWithTag:a]; UILabel *label = (UILabel *)[viewForCell viewWithTag:a]; NSString *str = label.text; } </code></pre> <p>Code of the method cellForRowAtIndexPath....</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"Cell"; UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; NSDictionary *dict = [appDelegate.webDataList objectAtIndex:indexPath.row]; tableView.backgroundColor = [UIColor colorWithRed:0.39 green:0.39 blue:0.39 alpha:0.39]; if([appDelegate.dataArray count]&gt;0){ imgView.backgroundColor = [UIColor clearColor]; imgView =[[UIView alloc ] initWithFrame:CGRectMake(0,0,320,45)]; imgView.tag= indexPath.row; [cell.contentView addSubview:imgView]; button=[UIButton buttonWithType:UIButtonTypeCustom]; button.frame=CGRectMake(291, 5, 19, 21); img =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"swap_re" ofType:@"png"]]; [button setBackgroundImage:img forState:UIControlStateNormal]; [button addTarget:self action:@selector(swapButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; button.tag= indexPath.row; [imgView addSubview:button]; button=[UIButton buttonWithType:UIButtonTypeCustom]; button.frame=CGRectMake(-25, 5, 19, 21); img =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"swap_re" ofType:@"png"]]; [button setBackgroundImage:img forState:UIControlStateNormal]; [button addTarget:self action:@selector(swapButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; button.tag= indexPath.row; [imgView addSubview:button]; button=[UIButton buttonWithType:UIButtonTypeCustom]; button.frame=CGRectMake(5, 7, 19, 21); button.tag = indexPath.row; img =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"delete" ofType:@"png"]]; [button setBackgroundImage:img forState:UIControlStateNormal]; [button addTarget:self action:@selector(deleteButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [imgView addSubview:button]; NSArray *arr = [[appDelegate.dataArray objectAtIndex:indexPath.row] componentsSeparatedByString:@"/"]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(34,9,140,20)]; label.text = [arr objectAtIndex:1]; label.tag = indexPath.row; [label setFont:[UIFont fontWithName:@"Georgia" size:14]]; [label setNumberOfLines:0]; label.textAlignment = UITextAlignmentLeft; label.textColor = [UIColor whiteColor]; label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; label.backgroundColor = [UIColor clearColor]; [imgView addSubview:label]; [label release]; label = [[UILabel alloc] initWithFrame:CGRectMake(181, 7, 75, 20)]; label.tag = indexPath.row; label.text = [dict1 objectForKey:@"time"]; [label setFont:[UIFont fontWithName:@"Georgia" size:16.0]]; label.textAlignment = UITextAlignmentLeft; [label setBackgroundColor:[UIColor clearColor]]; label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [label setTextColor:[UIColor whiteColor]]; [imgView addSubview:label]; [label release]; } return cell; } </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