zoukankan      html  css  js  c++  java
  • 【提问】iOS UIAtumator 是怎么判断元素isVisible的?

    脚本:

    var target = UIATarget.localTarget();
    
    var app = target.frontMostApp();
    var window = app.mainWindow();
    //window.logElementTree();
    
    var elements = window.elements();
    
    for ( var i = 0; i < elements.length; i++) {
    	UIALogger.logMessage("visible:"+elements[i].isVisible());	
    }
    

    如图:界面有4个元素,都是可见的。但是打印出来,只有第一个元素的isVisible是true。

    接着我尝试了,将源码另外三个的hidden 或 accessibilityElementsHidden 属性设置成YES,打印出的结果,都没有变化。

    ps:这个时候,我尝试把第一个UILabel的 hidden 或 accessibilityElementsHidden 属性进行修改,生效了。下边是我的代码:

    -(void)draw{
        UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(5.0f, 5.0f, 310.0f, 16.0f)];
        
        title.text = self.itemTitle;
        title.textColor = [UIColor blackColor];
        title.font = [UIFont fontWithName:@"FZZhongDengXian-Z07S" size:16];
        title.backgroundColor = [UIColor clearColor];
        title.accessibilityElementsHidden = YES;
        [self addSubview:title];
        
        //图片
        UIImageView *itemImage =[[UIImageView alloc] initWithFrame:CGRectMake(0, 24,320, 330)];
        NSURL *imageURL = [NSURL URLWithString:self.imageUrl];
        UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
        
        itemImage.image=image;
        [self addSubview:itemImage];
        
        //价格
        UILabel *name=[[UILabel alloc] initWithFrame:CGRectMake(5.0f,360.0f, 320.0f,14.0f)];
        name.text=[NSString stringWithFormat:@"%@%@",@"价格:¥",self.itemPrice];
        name.font = [UIFont systemFontOfSize:14];
        name.textColor = [UIColor redColor];
        [self addSubview:name];
        
        //描述
        UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(5.0f, 375.0f, 310.0f, 56.0f)];
        
        description.text = self.itemDescription;
        description.textColor = [UIColor blackColor];
        description.font = [UIFont systemFontOfSize:14.0f];
        description.numberOfLines = 0;//相当于不限制行数
        [self addSubview:description];
        
    }
  • 相关阅读:
    python模块导入
    linux总结shell
    linux和shell关系
    gdb调试工具
    C语言.c和.h
    CSS cursor 属性
    html dom SetInterVal()
    css hover伪类选择器与JQuery hover()方法
    CSS 清除浮动 clear 属性
    block,inline和inline-block概念和区别
  • 原文地址:https://www.cnblogs.com/dw729/p/3473711.html
Copyright © 2011-2022 走看看