【问题标题】:Add UILabel above UISearchBar and UITableView like WhatsApp Contacts在 UISearchBar 和 UITableView 上方添加 UILabel,如 WhatsApp 联系人
【发布时间】:2011-06-17 12:51:05
【问题描述】:

我在 UITableView 的标题上有 UISearchBar,我想在 UISearchBar 上方添加 UILabel。 UILabel 首次隐藏,当用户向下滚动 TableView 时,会出现 UILabel。它是在 WhatsApp 的“联系人”选项卡中完成的。

最好的方法是什么?任何帮助将不胜感激。

问候

【问题讨论】:

    标签: iphone ios uitableview uilabel uisearchbar


    【解决方案1】:

    一种方法是在 UIView 中添加 UILabel、UISearchBar 和 UITableView。

    否则,在第一行添加 UILabel,在第二行添加搜索栏,然后继续...

    【讨论】:

      【解决方案2】:

      目前无法测试,但我认为:

       theHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - HEADER_HEIGHT, 320, HEADER_HEIGHT)]
      
       headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, HEADER_HEIGHT)];
       headerLabel.textAlignment = UITextAlignmentCenter;
      

      另外不要忘记将子视图添加到标题中: [theHeader addSubview:headerLabel] 并在CGRectMake 内或定义的(例如#define HEADER_HEIGHT 52.0f)内为您的标题设置高度

      让我知道它是否有效!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-07-20
        • 1970-01-01
        • 2014-01-17
        • 1970-01-01
        • 2015-10-18
        • 2017-09-07
        • 2015-12-21
        相关资源
        最近更新 更多