表视图选定的索引方法不起作用(推送)
我的选项卡栏应用程序的第一个选项卡上有一个表格视图。然后,当单击任何行时,我想要推送 secondaryviewController 的视图。并且有标签。标签的文本必须是所选行的文本。我尝试这样做,但没有进入第二个选项卡:S 我该怎么做???另外在第二个ViewController类有3个视图。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
// ...
// Pass the selected object to the new view controller.
NSUInteger row2 = [indexPath row];
denemelik=row2;
[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController.enyakinfirma.text= [ws2.CustomerName objectAtIndex:[indexPath row]];
NSLog(@"kontrol2 %@",ws2.CustomerName);
[detailViewController release];
}
there is a table view at my tab bar application' s firs tab. Then when click any row I want to do pushing secondviewController' s view. and there is label. The label's text must be selected row's text. I try this but not enter second tab :S How can I do this??? Also at secondViewController class have 3 view.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
// ...
// Pass the selected object to the new view controller.
NSUInteger row2 = [indexPath row];
denemelik=row2;
[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController.enyakinfirma.text= [ws2.CustomerName objectAtIndex:[indexPath row]];
NSLog(@"kontrol2 %@",ws2.CustomerName);
[detailViewController release];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设
enyakinfirma
是您想要用文本填充的UILabel
。在实际创建和加载标签之前,您无法将文本分配给标签。这会在你推送新的视图控制器之后发生。因此,您需要创建一个单独的 @property 来跟踪您需要的文本:
当您创建视图控制器时,您分配此属性:
并在视图控制器的 viewDidLoad 中> 更新文本的方法。
I assume that
enyakinfirma
is yourUILabel
that you want to populate with the text. You cannot assign text to the label before the label is actually created and loaded. And that happens later, after you push the new view controller.Thus you need to create a separate
@property
in order to keep track of this text you need:When you create the view controller you assign this property:
And in your view controller's
viewDidLoad
method you update the text.