【问题标题】:Programmatically created UITextField hides other controls以编程方式创建的 UITextField 隐藏了其他控件
【发布时间】:2013-04-01 09:30:19
【问题描述】:

我需要动态创建一些控制器。在此处提供的图像中,我以编程方式添加了一个 UITextField(名称),它隐藏了 UITableView。

UITableView 默认隐藏。当用户触摸它上面的UIButton 时,UITableVIew 就会出现。

UITableView 出现时我的问题是,我怎样才能使UITableView 成为所有其他控件的顶部?

【问题讨论】:

  • 在添加文本字段后将tableView带到视图的前面.. [self.view bringSubviewToFront:tableView];希望这会有所帮助
  • @coder284 thnx,答案在您的评论中...

标签: iphone objective-c uitableview uiview uitextfield


【解决方案1】:

您将不得不更改顺序。 先添加 UItextfield

[self.view addSubview:yourTextField];

并在该行代码之后添加 tableview 和其他视图,以便它们出现在其上方。

[self.view addSubview:yourTableView];

【讨论】:

  • 哦,那我想bringSubviewToFront 将是最好的选择。这是我看到截图的第一个想法。 :)
【解决方案2】:

试试

[self.view bringSubviewToFront: yourTableView];

【讨论】:

    【解决方案3】:

    我认为这会很好,所以请实施这个。

     UITextField *txtFld = [[UITextField alloc] initWithFrame:CGRectMake(65, 300, 200, 30)];
        txtFld.backgroundColor = [UIColor clearColor];
        // Border Style None
        [txtFld setBorderStyle:UITextBorderStyleNone];
        [txtFld setPlaceholder:@"Name"];
    
        [self.view addSubview:txtFld];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-20
      相关资源
      最近更新 更多