0
我有一個iPhone應用程序,我想要獲取用戶可點擊的共同列表。我想自動化測試,並有一個客戶端應用程序在屏幕上點擊,但只是選擇隨機座標並不理想,所以肯定可以點擊的座標列表會更好。iPhone:獲取可可觸摸屏上的可點擊區域列表
到目前爲止,我有這是頂層窗口通過視圖:
getSubViewsCoords:(UIView *)view {
iAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
for (UIView *tempView in [view subviews]) {
// check if view responds to touch i.e. is an interactive view.
// go up through responder chain
// check if it reacts
// if it does then add to the gorilla's list
UIView *responderObj = tempView;
while (responderObj = [responderObj nextResponder]) {
if([responderObj respondsToSelector:@selector(touchesBegan:withEvent:)]){
// get xy etc and add to instance var
//then recall this function
// convert to top level windows co-ordinate system.
CGRect viewRect = [tempView convertRect:[tempView bounds] toView:nil];
clickableAreas = [clickableAreas stringByAppendingString: NSStringFromCGRect(viewRect)];
clickableAreas = [clickableAreas stringByAppendingString: @"\n"];
break;
}
}
[self getSubViewsCoords:tempView];
這是正確的方式去嗎?有沒有更簡單的方法來獲取這些信息?
在此先感謝您的幫助。