0

I am making use of a Presentation: Form Sheet in my app. So my ViewController gets displayed as a form with the black semi-transparent overlay around it.

I have implemented the logic to dismiss everything should the user tap anywhere outside my form sheet ViewController.

I would like to test this behavior but I'm not sure how to simulate the tap. How can I set an accessibility label to simulate this tap with a UI test?

Or any other suggestions how I can test this behavior?

Thanks!

4

2 回答 2

1

您只想单击屏幕上的任意位置以关闭所有内容吗?

    [tester tapScreenAtPoint:CGPoint];

为你做。

关于 KIF 的大部分内容都在这里解释: http ://www.raywenderlich.com/61419/ios-ui-testing-with-kif

于 2014-07-24T20:43:14.533 回答
0

嗨,您可以像这样使用UITapGestureRecognizer

首先创建一个UITapGestureRecognizer的实例

UITapGestureRecognizer *tapGesture = tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(someMethod:)];

然后将此手势识别器附加到您的视图(即您正在谈论的黑色覆盖)

[self.view addGestureRecognizer:tapGesture];

然后实现someMethod:这是当你的表单被点击时被调用的方法(动作)

-(void)someMethod
{
 //Logic to dismiss your formsheet 
}

:D

于 2014-07-24T15:44:16.670 回答