UISearchBar Scope Bar Position?

匿名 (未验证) 提交于 2019-12-03 08:50:26

问题:

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?

Thanks in advance.

回答1:

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) {      }  } 

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)

Hope that helps maybe someone else.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!