UISearchBar 范围栏位置? [英] UISearchBar Scope Bar Position?

查看:26
本文介绍了UISearchBar 范围栏位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iPad 应用程序上,我想知道是否可以将范围栏从右侧移动到我的 UISearchBar 到另一个位置?

I am here on an iPad Application and i would like to know if its possible to move the Scope Bar from right to my UISearchBar to another position?

我希望在我的搜索栏下有我的范围栏.这可能吗?

I would like to have my Scope Bar under my Search Bar. Is that possible?

提前致谢.

推荐答案

好的,这就是我的解决方案.我将实现我自己的分段控件以创建搜索范围的可能性.

Ok this is my solution for that. Ill implemented my own segmented control to create a possibility for a search scope.

    let categories = ["Scope1", "Scope2", "Scope3"]
    segmentedControl.addTarget(self, action: "changeScope:", forControlEvents: .ValueChanged) 
    segmentedControl.frame = CGRectMake(8, 5, 800, 30)
    segmentedControl.backgroundColor = UIColor.whiteColor()
    segmentedControl.tintColor = UIColor.darkGrayColor()

    // add it in a scrollView, because ill got too much categories here. Just if you need that:

    scrollView.contentSize = CGSizeMake(segmentedControl.frame.size.width + 16, segmentedControl.frame.size.height-1)
    scrollView.showsHorizontalScrollIndicator = false;
    // set first category
    segmentedControl.selectedSegmentIndex = 0
    scrollView.addSubview(segmentedControl)

这是作用域栏的功能,当用户切换作用域时,请随心所欲:

Here is the function for the scope bar, do wantever you want when a user switches a scope:

func changeScope(sender: UISegmentedControl) {
    switch(sender.selectedSegmentIndex) { 
    }
 }

在我的例子中,我从一个 Web 服务中得到了几个 resultArrays,并且只显示了选择的结果(通常将它们添加到 1 个巨大的结果集)

In my case, ill got several resultArrays from an Webservice, and ill only show the selected result (normally ill Add them to 1 huge resultSet)

希望能帮助其他人.

这篇关于UISearchBar 范围栏位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆