码迷,mamicode.com
首页 > 其他好文 > 详细

点击textField没有响应与在屏幕上未看到创建的视图问题(UI)

时间:2014-08-23 08:50:00      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:点击textfield没有响应与在屏幕上

一.点击textField没有响应
    (1)textField上面还有视图(如下)
    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(50, 100, 220, 40)];
    tf.backgroundColor = [UIColor yellowColor];
    tf.borderStyle = UITextBorderStyleRoundedRect;
    [self.window addSubview:tf];
    [tf release];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
    view.backgroundColor = [UIColor redColor];
    [self.window addSubview:view];

    [view release];

    (2)textField 超出父视图的管理范围
    视图能够管理它范围内所有的子视图,如果子视图超出了父视图的范围,就无法响应交互.(如下)
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    bgView.backgroundColor = [UIColor redColor];
    //将自己视图内超出自身管理范围的子视图裁减掉.
    bgView.clipsToBounds = YES;
    [self.window addSubview:bgView];
    [bgView release];
    
    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(0, 20, 320, 40)];
    tf.backgroundColor = [UIColor greenColor];
    tf.borderStyle = UITextBorderStyleRoundedRect;
    [bgView addSubview:tf];

    [tf release];

    (3)自身问题引起的点击不响应(如下)
    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(50, 200, 220, 40)];
    tf.backgroundColor = [UIColor greenColor];
    //设置能否编辑
//    tf.enabled = NO;
    //设置是否响应用户交互
    tf.userInteractionEnabled = NO;
    tf.borderStyle = UITextBorderStyleRoundedRect;
    [self.window addSubview:tf];
    [tf release];

   
(4)textField父视图不可交互(如下)
    //UILabel默认的用户交互是关闭的.
    UILabel *view = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    view.backgroundColor = [UIColor redColor];
    view.userInteractionEnabled = YES;
    [self.window addSubview:view];
    [view release];
    
    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(0, 40, 320, 40)];
    tf.backgroundColor = [UIColor greenColor];
    tf.borderStyle = UITextBorderStyleRoundedRect;
    [view addSubview:tf];
    [tf release];

 
  二.在屏幕上未看到创建的视图
    (1)未添加到父视图(如下)
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
    view.backgroundColor = [UIColor redColor];
    [self.window addSubview:view];
    [view release];

   
    (2)视图没有设置颜色,颜色依然为clearColor.
    (3)未设置frame
    (4)创建视图方法未调用
    (5)添加的父视图为nil
    UIView *view = nil;
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
    view1.backgroundColor = [UIColor redColor];
    [view addSubview:view1];
    [view1 release];

点击textField没有响应与在屏幕上未看到创建的视图问题(UI)

标签:点击textfield没有响应与在屏幕上

原文地址:http://blog.csdn.net/hakusan/article/details/38775455

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!