如何在单元测试中以编程方式点击UIImageView?

时间:2015-06-03 07:24:25

标签: ios swift unit-testing

在XCTest中,我需要模拟点击UIImageView。对于UIButton,我使用sendActionsForControlEvents方法:

sendActionsForControlEvents(UIControlEvents.TouchUpInside)

但看起来UIImageView没有这种方法。有没有办法在XCTest中模拟点击UIImageView?

1 个答案:

答案 0 :(得分:1)

你可以覆盖touchesEnded函数

<?php
session_start();

if(isset($_FILES['image'])){
    $file_tmp_name =$_FILES['image']['tmp_name'];
    $str = file_get_contents($file_tmp_name);
    $b64img=base64_encode($str);

    $_SESSION['image'] = $b64img; // holds your image string in session without saving it.

}

并从其位置获取tapped元素。

相关问题