i am setting a value of a label in the following delegate开发者_StackOverflow method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I am able to see that value in table view too but wen i try to get the value in didselect method of table view i am getting null instead , that also only for 0th row.
Please help.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
AMDEL_DCV.showmap=FALSE;
AMDEL_DCV.indexno=indexPath.row;
UITableViewCell *cell1=[tableView cellForRowAtIndexPath:indexPath];
UILabel *lbltemp=(UILabel *)[cell1 viewWithTag:indexPath.row];
//AMDEL_DCV.distanceval is global in app delegate
AMDEL_DCV.distanceval=lbltemp.text;
NSLog(@"Label Text %@ and lbltemp teg%d",[NSString stringWithFormat:@"%@",lbltemp.text],lbltemp.tag);
//[[NSNotificationCenter defaultCenter] removeObserver:self];
LocationsMap *LM1catView=[[LocationsMap alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[[self.superview layer] addAnimation:animation forKey:nil];
[self.superview addSubview:LM1catView];
[LM1catView release];
[self removeFromSuperview];
}
My guess is you're not actually getting a pointer to your UILabel, not that your UILabel's text is nil. -[UIView viewWithTag:]
will only return the sub view that has its tag
property set to the value you're asking. Because of the way UITableViewCells are reused, setting a different tag for the same label in each cell of at UITableView is probably a bad idea. You may have better luck using cell1.textLabel
instead.
精彩评论