在我的应用程序中,我添加了两个带导航栏的UIBarButtonItem。在iOS6及以下版本中,它看起来像这样

但当我在iOS7中运行我的应用程序时,它看起来

问题是:刷新按钮关闭。所以请帮我显示与“今天”按钮相等的刷新按钮。下面是我使用的代码,
UIBarButtonItem* todayButton = [[UIBarButtonItem alloc] initWithTitle:@"Today"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(showTodayAction:)];
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(refreshAction:)];
refreshButton.style = UIBarButtonItemStyleBordered;
UIBarButtonItem *negativeSeperator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
negativeSeperator.width = -12;
TransparentToolbar *toolbar = [[TransparentToolbar alloc] initWithFrame:CGRectMake(0, -5, 100, TOOLBAR_HEIGHT)];
toolbar.items = [NSArray arrayWithObjects:
negativeSeperator,
refreshButton, todayButton,
negativeSeperator,
nil];
UIView *toolbarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, TOOLBAR_HEIGHT)];
[toolbarView addSubview:toolbar];
UIBarButtonItem *toolbarItem = [[UIBarButtonItem alloc] initWithCustomView:toolbarView];
self.navigationItem.leftBarButtonItem = toolbarItem;发布于 2013-10-10 20:32:35
试着这样……对不起,我赶时间。
标记我的尝试次数
UIBarButtonItem* todayButton = [[UIBarButtonItem alloc] initWithTitle:@"Today"
style:UIBarButtonSystemItemRefresh
target:self
action:@selector(goBack)];
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(goBack)];
refreshButton.style = UIBarButtonItemStyleBordered;
UIBarButtonItem *negativeSeperator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
negativeSeperator.width = -12;
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
toolbar.items = [NSArray arrayWithObjects:
negativeSeperator,refreshButton, todayButton,
negativeSeperator,
nil];//
self.navigationItem.leftBarButtonItems = toolbar.items;发布于 2013-10-11 19:53:39
我认为不需要其他额外的视图,以下代码将完成您的工作:
UIBarButtonItem* todayButton = [[UIBarButtonItem alloc] initWithTitle:@"Today"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(showTodayAction:)];
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(refreshAction:)];
refreshButton.style = UIBarButtonItemStyleBordered;
self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:refreshButton, todayButton, nil];https://stackoverflow.com/questions/19293363
复制相似问题