2009-10-13 41 views
5

alt text http://img210.imageshack.us/img210/5992/searchdisplaycontroller.png自定义UISearchDisplayController

以下对象是否可自定义?

1的UISearchBar范围按钮(UISegmentedController)

2. UIResultsTableView

3.键盘(至少所以它的颜色为黑色)

+0

你用什么来产生它:一个笔尖或代码? – JoePasq 2009-10-19 23:09:01

+0

我正在使用代码。我能够自定义所有内容,谢谢大家的帮助,但我无法删除问题。 – Mark 2009-10-21 10:36:32

回答

1

我能够自定义通过使用以下代码tableview:

- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView { 
tableView.backgroundColor = [UIColor colorWithRed:(19.0/255.0) green:(19.0/255.0) blue:(19.0/255.0) alpha:1.0]; 
tableView.separatorColor = [UIColor blackColor]; } 

但是,当您触摸取消按钮时,界面将在返回原始表格视图之前闪烁白色。这怎么解决?

+0

我不得不从您的帖子中删除图片,因为ImageShack已将其删除并用广告替换。有关更多信息,请参阅http://meta.stackexchange.com/q/263771/215468。如果可能的话,你最好重新上传它们。谢谢! – Undo 2015-09-28 03:05:25

3

alt text http://img527.imageshack.us/img527/9775/searchdisplaycontrollerz.png

我能够破解排序的代码来改变分段控制:

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { 
for (UIView *subview in self.view.subviews) { 
    for (UIView *subview2 in subview.subviews) { 
     if ([subview2 isKindOfClass:[UISegmentedControl class]]) { 
      UISegmentedControl *segmentedControl = (UISegmentedControl *)subview2; 
      segmentedControl.tintColor = [UIColor blackColor]; 
      segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; 
     }   
    } 
}} 

但是按钮是巨大的,我该如何解决,这样他们也同样漂亮原本的?

1

尽管尝试每个segmentedControlStyle,我也从来没有能够让按钮变小。这里是我需要使用的代码,以至少在IOS4上获得正确的色调:

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { 
    static BOOL tintAlreadyChanged = NO; 
    if (tintAlreadyChanged) return; 

    NSLog(@"Searching subViews for UISegmentControl:"); 
    //fix segmented control 
    for (UIView *subview in self.view.subviews) { 
     //NSLog(@"\n\nsubView = %@",subview); 
     for (UIView *subview2 in subview.subviews) { 
      //NSLog(@"subView2 = %@",subview2); 
      for (UIView *subview3 in subview2.subviews) { 
       //NSLog(@"subView3 = %@",subview3); 
       if ([subview3 isKindOfClass:[UISegmentedControl class]]) { 
        NSLog(@"Found UISegment SubView = %@",subview3); 
        UISegmentedControl *segmentedControl = (UISegmentedControl *)subview3; 
        segmentedControl.tintColor = [UIColor blackColor]; 
        segmentedControl.segmentedControlStyle = UISegmentedControlStyleBezeled; 
        tintAlreadyChanged = YES; 
       } 
      }      
     } 
    } 
}