2014-10-10 67 views
4

我在iPad應用程序的這裏,我想知道是否有可能將範圍欄從右移到我的UISearchBar到另一個位置?UISearchBar Scope Bar位置?

enter image description here

我想有在我的搜索欄我的範圍吧。那可能嗎?

在此先感謝。

+0

這裏同樣的問題,非常感興趣,並且現在 – webo80 2015-10-28 11:30:01

+0

這裏沒有解決辦法是我的問題:http://stackoverflow.com/questions/33390408/positioning-of-scope-bar-in-uisearchcontroller – webo80 2015-10-28 11:58:04

+0

香港專業教育學院做到了這一點通過創建我自己的「分段控件」,並實現了像範圍欄一樣的功能! – derdida 2015-10-28 12:20:46

回答

2

好吧,這是我的解決方案。我實施了自己的分段控制來創建搜索範圍的可能性。

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) 

這裏是範圍欄的功能,做wantever你要當用戶切換範圍:

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

在我的情況下,生病了幾個resultArrays從web服務,病人只顯示選定的結果(通常不適合將它們添加到1個巨大的結果集)

希望可以幫助別人。

+0

我已經創建了一個有點靈感的版本,所以...謝謝! :) – webo80 2015-10-28 15:53:28