Iphone UITableview以编程方式选择起始单元格

Iphone UITableview以编程方式选择起始单元格,iphone,Iphone,我在iPhone应用程序中使用了UItableview。我使用Tableviewcell单击事件移动到下一个视图。但当我单击uinavigation的“后退”按钮时,tableview单元格选择与上一次单击相同 但是,我需要,当我单击导航的后退按钮时,光标位置移动到tableview的起始单元格 当我点击后退按钮时,表格视图会自动选择第一个单元格。我认为现在你的导航栏按钮只需弹出视图,你需要按下视图,这样你的应用程序就能重新加载包含表格的类的视图 在viewDidLoad中编写这行代码: sel

我在iPhone应用程序中使用了UItableview。我使用Tableviewcell单击事件移动到下一个视图。但当我单击uinavigation的“后退”按钮时,tableview单元格选择与上一次单击相同

但是,我需要,当我单击导航的后退按钮时,光标位置移动到tableview的起始单元格


当我点击后退按钮时,表格视图会自动选择第一个单元格。

我认为现在你的导航栏按钮只需弹出视图,你需要按下视图,这样你的应用程序就能重新加载包含表格的类的视图

在viewDidLoad中编写这行代码:

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Title Of Button" style:UIBarButtonItemStyleBordered target:self action:@selector(functionToPushView:)];

Now define the function like this:

-(void)functionToPushView: (id)sender
{
     YourClass *objYourClass = [[YourClass alloc] init];
     [[self navigationController] pushViewController:objYourClass animated:YES];
}

请记住,“YourClass”将是包含UITableView的类。

我认为现在您的导航栏按钮只需弹出视图,您需要按下视图,以便您的应用程序将重新加载包含表的类的视图

在viewDidLoad中编写这行代码:

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Title Of Button" style:UIBarButtonItemStyleBordered target:self action:@selector(functionToPushView:)];

Now define the function like this:

-(void)functionToPushView: (id)sender
{
     YourClass *objYourClass = [[YourClass alloc] init];
     [[self navigationController] pushViewController:objYourClass animated:YES];
}
记住,“YourClass”将是包含UITableView的类。

试试这个:

- (void)viewWillAppear:(BOOL)animated
{   
    NSIndexPath *ip = [NSIndexPath indexPathForRow: 0 inSection:0];
    [self.tableView selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionTop];
}
试试这个:

- (void)viewWillAppear:(BOOL)animated
{   
    NSIndexPath *ip = [NSIndexPath indexPathForRow: 0 inSection:0];
    [self.tableView selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionTop];
}
单击“上一步”按钮时,UITableview会自动选择单元格

单击“上一步”按钮时,UITableview会自动选择单元格