在UIPopoverController的页脚中使用UISegmentedControl [英] Using a UISegmentedControl in the footer of UIPopoverController

查看:110
本文介绍了在UIPopoverController的页脚中使用UISegmentedControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPad应用程序取景器中(


In my iPad app Viewfinder (iTunes Link), I'm trying to recreate the look of a UISegmentedControl as seen in the footer of Keynote's Build In popover:

The iPad HIG suggests using a bottom-aligned UIToolbar, but the appearance is incorrect. This screenshot shows Black Opaque, but none of the standard styles match Keynote.

Any advice on recreating the Keynote look would be appreciated. If you don't have Keynote on the iPad, you can see the same technique in the footer of the Bookmarks popover in Maps.

解决方案

What you need is to set the toolbarItems of your top UIViewController in your UIPopover and configure it properly. Consider something like this:

        NSArray *segmentedItems = [NSArray arrayWithObjects:@"Bookmarks", @"Recents", @"Contacts", nil];
        UISegmentedControl *ctrl = [[UISegmentedControl alloc] initWithItems:segmentedItems];
        ctrl.segmentedControlStyle = UISegmentedControlStyleBar;
        ctrl.selectedSegmentIndex = 0;

        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:ctrl];
        ctrl.frame = CGRectMake(0.0f, 5.0f, 320.0f, 30.0f);

        NSArray *theToolbarItems = [NSArray arrayWithObjects:item, nil];
        [self setToolbarItems:theToolbarItems];
        [ctrl release]; 
        [item release];

EDIT: Now i got it, just do not set the tintColor, it will inherit the correct color (whatever it is). The screenshot below now looks exactly like the one in the Google Maps App:

alt text http://www.memorylifter.com/services/dev/linklist/SCREENSHOT_TABBAT.png

这篇关于在UIPopoverController的页脚中使用UISegmentedControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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