- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的问题与来自 XCode 的 Instruments 工具的 UI 自动化模板有关。 UI 自动化如何支持 UIActionSheet 测试?我知道有一个 UIAActionSheet 元素,我能够在我的应用程序中获取它。但我不知道如何从操作表中获取和操作按钮。 UI 自动化不为这些按钮提供任何元素。 UI 自动化文档也没有关于此事的任何信息。请参阅下面的链接。看起来这个控件没有为按钮使用 UIButton 类,而是以某种特定的方式呈现它们。你能给我一些线索如何从 UIAActionSheet 到达按钮吗?谢谢。
最佳答案
我已经找到了使用直接攻丝模拟解决问题的方法。这不是一个很好的解决方案,但至少它是有效的。我在苹果开发者论坛上问过同样的问题,但没有得到任何回应。
所以,下面的函数就是我的解决方案。我已经对其进行了测试,并且性能良好。我仍将继续寻找更好的方法。
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/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!