【问题标题】:Why buttons added to my navigationitem looks like inactive?为什么添加到我的导航项的按钮看起来不活动?
【发布时间】:2011-10-20 12:46:02
【问题描述】:

我有一个带有 splitViewController 的 iPad 应用程序。在我的 RootViewController 我添加按钮来编辑项目列表并添加新项目

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.clearsSelectionOnViewWillAppear = NO;
    self.contentSizeForViewInPopover = CGSizeMake(320.0, 500.0);

    //  Configure the Edit button
    [[self navigationItem] setLeftBarButtonItem:[self editButtonItem]];

    //  Configure the Add button
    UIBarButtonItem * addButton = [[UIBarButtonItem alloc] 
                                   initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                                   target:self
                                   action:@selector(add)];



    [[self navigationItem] setRightBarButtonItem:addButton];
    [addButton release];

}

它工作正常。按钮轻按。调用选择器。但是按钮看起来像是处于非活动状态(灰色)。标题也是灰色的。为什么?

我需要做些什么来给他们一个标准的布局?

【问题讨论】:

  • 哪个按钮?编辑按钮?还是添加按钮?
  • 编辑和添加以及标题。
  • 你能截图并附在你的帖子上吗,我看不出你的代码有什么问题。
  • 这里是屏幕截图的链接pics.livejournal.com/torgvi/pic/000cd6kr 我无法将其附加到帖子中,因为我没有足够的声望点,抱歉。
  • 这实际上是 iPad 分屏控制器的正确默认颜色

标签: objective-c ios xcode uinavigationitem


【解决方案1】:

可能是为了这一行。评论这一行

self.clearsSelectionOnViewWillAppear = 否;

【讨论】:

    【解决方案2】:

    从您的屏幕截图中,BarButtonItems 的颜色是 UISplitViewController 的正确和默认颜色。

    如果您想自定义 BarButtonItems 的颜色,您可以通过提供 tintColor 来实现,该 tintColor 将修改按钮的颜色。

    addButton.tintColor = [UIColor redColor];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      相关资源
      最近更新 更多