iPhone UIAutomation:执行 logElementTree() 时不显示动态添加的 UI 元素

发布于 2024-11-16 00:41:46 字数 1500 浏览 6 评论 0原文

我有以下 UI 元素层次结构:

UITableView
- UITableViewCell
-- UIScrollView
--- UIWebView
--- UIWebView
--- UIWebView

现在,当我最初加载页面时,这就是显示的全部内容。但是,如果用户向右滚动,则会在用户遇到其他 UIWebView 时加载它们。例如,如果用户向右滚动多次,第四个 UIWebView 将被插入到 UIScrollView 中。

现在,当我最初加载包含所有这些元素的屏幕时,如果我在页面上执行 logElementTree(),将显示我列出的所有元素。例如,我可能会看到以下输出:

4) UIATableView [name:Empty list value:rows 1 to 1 of 1 rect:{{x:0, y:64}, {width:320, height:416}}]
5) UIATableCell [name:OfferCardTableViewCell value:(null) rect:{{x:0, y:160}, {width:320, height:416}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:0, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:320, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:640, y:160}, {width:320, height:418}}]

但是,如果我向右滚动并将其他 UIWebView 添加到三个现有 UIWebView 中,则在执行 logElementTree() 时,新的 UIWebView 元素不会显示。我确实注意到 x 坐标已更新。例如,滚动到 UIScrollView 中的第四项后,UIAWebView 将显示为以下坐标:

6) UIAWebView [name:(null) value:(null) rect:{{x:-960, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:-640, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:-320, y:160}, {width:320, height:418}}]

作为参考,新创建的 UIWebView 通过调用 [scrollView addSubView:]< /代码>。我需要做什么才能在执行 logElementTree() 时显示新创建的 UIWebView?

谢谢。

I have the following hierarchy of UI Elements:

UITableView
- UITableViewCell
-- UIScrollView
--- UIWebView
--- UIWebView
--- UIWebView

Now, when I the page initially loads, this is all that is displayed. But, if the user scrolls to the right, additional UIWebViews will load as the user encounters them. For example, if the user were to scroll to the right multiple times as fourth UIWebView would be inserted into the UIScrollView.

Now, when I initially load the screen that contains all of these elements, if I execute logElementTree() on the page, all of the elements that I have listed will be displayed. For example, I might see the following output:

4) UIATableView [name:Empty list value:rows 1 to 1 of 1 rect:{{x:0, y:64}, {width:320, height:416}}]
5) UIATableCell [name:OfferCardTableViewCell value:(null) rect:{{x:0, y:160}, {width:320, height:416}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:0, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:320, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:640, y:160}, {width:320, height:418}}]

But, if I scroll to the right and additional UIWebViews get added to the three existing UIWebViews the new UIWebView elements do not show up when executing logElementTree(). I do notice that the x-coordinate has been updated. For example, after scrolling to the fourth item in the UIScrollView, the UIAWebViews would be displayed with the following coordinates:

6) UIAWebView [name:(null) value:(null) rect:{{x:-960, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:-640, y:160}, {width:320, height:418}}]
6) UIAWebView [name:(null) value:(null) rect:{{x:-320, y:160}, {width:320, height:418}}]

For reference, the newly created UIWebViews are added to the UIScrollView by invoking [scrollView addSubView:<new_UIWebView_object>]. What do I need to do so that the newly created UIWebViews show up when I execute logElementTree()?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

游魂 2024-11-23 00:41:46

要解决此问题,您需要在添加或删除元素时使用 UIAccessibilityPostNoficiation 函数。 UIAccessibilityLayoutChangedNotification 通知可能会起作用。如果失败,请尝试 UIAccessibilityScreenChangedNotification

To work around this problem, you need to use the UIAccessibilityPostNoficiation function when an element is added or removed. The UIAccessibilityLayoutChangedNotification notification will probably work. Failing that, try UIAccessibilityScreenChangedNotification.

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