表视图选定的索引方法不起作用(推送)

发布于 2024-12-12 07:06:09 字数 767 浏览 0 评论 0原文

我的选项卡栏应用程序的第一个选项卡上有一个表格视图。然后,当单击任何行时,我想要推送 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无远思近则忧 2024-12-19 07:06:09

我假设 enyakinfirma 是您想要用文本填充的 UILabel 。在实际创建和加载标签之前,您无法将文本分配给标签。这会在你推送新的视图控制器之后发生。

因此,您需要创建一个单独的 @property 来跟踪您需要的文本:

// SecondViewController.h
@interface SecondViewController {
    NSString *customerName;
}    
@property (nonatomic, retain) NSString *customerName;
@end

当您创建视图控制器时,您分配此属性:

detailViewController.customerName = ...;

并在视图控制器的 viewDidLoad 中> 更新文本的方法。

-(void)viewDidLoad {
    // ...
    enyakinfirma.text = self.customerName;
}

I assume that enyakinfirma is your UILabel 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:

// SecondViewController.h
@interface SecondViewController {
    NSString *customerName;
}    
@property (nonatomic, retain) NSString *customerName;
@end

When you create the view controller you assign this property:

detailViewController.customerName = ...;

And in your view controller's viewDidLoad method you update the text.

-(void)viewDidLoad {
    // ...
    enyakinfirma.text = self.customerName;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文