【发布时间】:2013-02-19 18:49:09
【问题描述】:
我只想将 UITableViewCell 的标签(这是一个简单的字符串)复制到 nextView 的 UIlabel 中。 我尝试在 nextView 中创建一个字符串属性并将其传递给单元格标签, 但它不起作用。 我在 nextView 中得到零, 这是为什么?这是我的 didSelectRowAtIndexPath 方法 在 rootViewController.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *selLabel =[tempArray objectAtIndex:indexPath.row];
DetailViewController *detailViewCont=[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];
detailViewCont.selectedLabel=selLabel;
[self.navigationController pushViewController:detailViewCont animated:YES];
NSLog(@"selected Label %@",detailViewCont.selectedLabel);
}
最后一个 NSlog 语句在这里返回正确的字符串。
在 nextViewController.m 中
-(void)viewDidLoad
{
[super viewDidLoad];
selectedLabel=[[NSString alloc]init];
UILabel *label1=[[UILabel alloc]init];
label1.frame=CGRectMake(5,5,310, 60);
label1.font=[UIFont fontWithName:@"Arial Black" size:20];
label1.text=selectedLabel;
NSLog(@"sellabel %@",selectedLabel);
[self.View addSubview:label1];
}
这里的NSLog语句返回null
【问题讨论】:
-
是
selLabelnil?是tempArraynil? -
查看我更新的问题
标签: ios objective-c uitableview uilabel nslog