Objective c 表视图所选索引方法无效(推送)
在我的tab bar应用程序的firs选项卡上有一个表视图。然后单击要执行的任何行时,按secondviewController的视图。还有一个标签。标签的文本必须是选定行的文本。我尝试了这一点,但没有进入第二个选项卡:S我如何才能做到这一点???同样在secondViewController类中有3个视图Objective c 表视图所选索引方法无效(推送),objective-c,ios,uitabbarcontroller,uitableview,selectedindex,Objective C,Ios,Uitabbarcontroller,Uitableview,Selectedindex,在我的tab bar应用程序的firs选项卡上有一个表视图。然后单击要执行的任何行时,按secondviewController的视图。还有一个标签。标签的文本必须是选定行的文本。我尝试了这一点,但没有进入第二个选项卡:S我如何才能做到这一点???同样在secondViewController类中有3个视图 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- (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];
}我假设
enyakinfirma
是您希望用文本填充的UILabel
。在实际创建和加载标签之前,不能将文本指定给标签。然后,在推送新的视图控制器之后,就会发生这种情况
因此,您需要创建一个单独的@属性
,以便跟踪您需要的文本:
// SecondViewController.h
@interface SecondViewController {
NSString *customerName;
}
@property (nonatomic, retain) NSString *customerName;
@end
创建视图控制器时,请指定此属性:
detailViewController.customerName = ...;
在视图控制器的viewDidLoad
方法中更新文本
-(void)viewDidLoad {
// ...
enyakinfirma.text = self.customerName;
}
那么secondViewController类是否还有另一个2视图?不推第二视图:(我试过你的解决方案,但仍然不起作用。)你对此有什么想法吗??