gpt4 book ai didi

iOS/UI 自动化 : UIAActionSheet does not have possibilities to manipulate with buttons

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:55:19 25 4
gpt4 key购买 nike

我的问题与来自 XCode 的 Instruments 工具的 UI 自动化模板有关。 UI 自动化如何支持 UIActionSheet 测试?我知道有一个 UIAActionSheet 元素,我能够在我的应用程序中获取它。但我不知道如何从操作表中获取和操作按钮。 UI 自动化不为这些按钮提供任何元素。 UI 自动化文档也没有关于此事的任何信息。请参阅下面的链接。看起来这个控件没有为按钮使用 UIButton 类,而是以某种特定的方式呈现它们。你能给我一些线索如何从 UIAActionSheet 到达按钮吗?谢谢。

http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIAActionSheetClassReference/UIAActionSheet/UIAActionSheet.html#//apple_ref/doc/uid/TP40009895

最佳答案

我已经找到了使用直接攻丝模拟解决问题的方法。这不是一个很好的解决方案,但至少它是有效的。我在苹果开发者论坛上问过同样的问题,但没有得到任何回应。

所以,下面的函数就是我的解决方案。我已经对其进行了测试,并且性能良好。我仍将继续寻找更好的方法。

function tapActionSheetButton(target, actionSheet, buttonIndex)
{
var headerHeight = 28;
var buttonHeight = 50;

if (buttonIndex >= 0)
{
var actionSheetRect = actionSheet.rect();
UIALogger.logMessage("actionSheet:{rect:{origin:{x:" + actionSheetRect.origin.x.toString()
+ ", y:" + actionSheetRect.origin.y.toString()
+ "}, size:{width:" + actionSheetRect.size.width.toString()
+ ", height:" + actionSheetRect.size.height.toString()
+ "}}}");
var xOffset = actionSheetRect.size.width / 2;
var yOffset = headerHeight + buttonIndex * buttonHeight + buttonHeight / 2;
if (yOffset < actionSheetRect.size.height) {
var tap_x = actionSheetRect.origin.x + xOffset;
var tap_y = actionSheetRect.origin.y + yOffset;
target.tap({x:tap_x, y:tap_y});
}
}
else
{
var message = "Cannot tap button " + buttonIndex.toString() + ". It does not exist";
throw message;
}
}

关于iOS/UI 自动化 : UIAActionSheet does not have possibilities to manipulate with buttons,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5250201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com