自定义 UISearchDisplayController

发布于 2024-08-07 02:22:31 字数 336 浏览 6 评论 0原文

替代文本 http://img210.imageshack.us/img210/5992/searchdisplaycontroller.png

以下是对象可定制?

1. UISearchBar 范围按钮 (UISegmentedController)

2. UIResultsTableView

3.键盘(至少是黑色的)

alt text http://img210.imageshack.us/img210/5992/searchdisplaycontroller.png

Are the following objects customizable?

1. UISearchBar Scope Buttons (UISegmentedController)

2. UIResultsTableView

3. Keyboard (at least so it's colored black)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你的笑 2024-08-14 02:22:31

替代文本 http://img527.imageshack.us/img527/9775/searchdisplaycontrollerz.png< /a>

我能够通过某种黑客代码更改分段控件:

- (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;
        }           
    }
}}

但是按钮很大,我该如何修复它,使它们与原始按钮一样漂亮?

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

I was able to change the segmented control by a sort-of hack code:

- (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;
        }           
    }
}}

However the buttons are HUGE, how could I fix it so they are just as pretty as the original?

死开点丶别碍眼 2024-08-14 02:22:31

尽管尝试了每一种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;
                }
            }                       
        }
    }
}

I was also never able to get the buttons to be smaller despite trying every segmentedControlStyle. Here's the code I needed to use to at least get the tint color correct on 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;
                }
            }                       
        }
    }
}
旧夏天 2024-08-14 02:22:31

我可以使用以下代码自定义表格视图:

- (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]; }

但是,当您触摸取消按钮时,界面将闪烁白色,然后返回原始表格视图。如何解决这个问题?

I was able to customize the tableview by using the following code:

- (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]; }

However when you touch the cancel button, the interface will flash white before going back to the original tableview. How can this be fixed?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文