0

如何将第一个 tableview 行数据传递给第二个详细视图行

我用 [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];

或者

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

在每个单元格中显示披露按钮

可以,我还添加了动作

- (void)tableView:(UITableView *)tableViewaccessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{

NSLog(@"disclosure button %@ touched",indexPath.row);   

}

但是当我触摸披露按钮时,控制台中什么也没有显示

比我添加动作

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

// carry Alarm Name text into sub-table-view to look for detail time and text info
NSLog(@"Alarm Name = %@", [alarmName objectAtIndex:indexPath.row]);
NSLog(@"Index Path Raw# = %i", indexPath.row);

// Navigation logic may go here. Create and push another view controller.
AlarmDetailTableViewController *detailViewController = [[AlarmDetailTableViewController alloc] initWithNibName:@"AlarmTableViewController" bundle:[NSBundle mainBundle]];
// ...
// Pass the selected object to the new view controller.

[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
 detailViewController = nil;

}

它可以在控制台模式下通知

但我认为当我触摸第一级 TableView 中的任何行时,它总是出现相同的详细信息视图

如何使用第一级的数据显示新的详细视图?

例如

使 tableView1.row0.text = detail view.title

并在标题下显示其他数据

如果你需要代码我可以上传

我的老板说这不是什么大秘密......

非常感谢

4

2 回答 2

3

也许问题出在您的:

- (void)tableView:(UITableView *)tableViewaccessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{

应该是:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
于 2010-10-08T21:11:44.787 回答
0

好的,如果您点击附件按钮而不是显示另一个详细信息视图

我们需要添加一个详细视图

首先创建一个“ new navigation based application”,例如 FirstView

右键单击类文件夹并选择“ add new File”选择您要显示的新视图

例如,我选择了一个名为“ DetailView”的新表格视图

比先去 DetailView.m 去给一个部分和行号

或声明布局

比回到 FirstView.h

添加#import DetailView

转到 FirstView.m

找到这个方法- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

并使用 DetailView 子类创建一个新视图

添加这样的代码

DetailView *detailView =[[DetailView alloc]init];
detailView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:detailView animated:YES];

您可以添加要显示的任何视图

于 2010-10-05T01:35:52.483 回答