【发布时间】:2016-01-14 07:17:13
【问题描述】:
我的视图层次结构如下:
-UIScrollView
--UITableView
---UIView
我在项目中的所有代码都是:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:scrollView];
UITableView *tableView = [[UITableView alloc] initWithFrame:scrollView.bounds];
tableView.delegate = self;
tableView.dataSource = self;
[scrollView addSubview:tableView];
UIView *tableSubView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 20)];
[tableView addSubview:tableSubView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *idForCell = @"id";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:idForCell];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:idForCell];
}
cell.textLabel.text = [NSString stringWithFormat:@"%@",@(indexPath.row)];
return cell;
}
我在自动化中的 js 代码是:
var target = UIATarget.localTarget();
target.delay(2);
target.logElementTree();
最后我通过仪器检查了 Trace Log 中的元素树显示,结果是:
-UIATarget
--UIAApplication
---UIAWindow
----UIAScrollView
-----UIATableView
------UIATableCell
------UIATableCell
------UIATableCell
但是我找不到tableSubView元素,有谁能告诉我原因吗?TKS非常多!
【问题讨论】:
标签: ios ios-ui-automation xcode-instruments