“Plain Style unsupported in a Navigation Item” warning with my customized Bar Button Item

前端 未结 8 890
醉话见心
醉话见心 2020-12-24 11:39

I drag a Round Rect Button to the position of the right Bar Button Item, and set an image to the Round Rect Button. All works well, except the warning \"Plain Style unsuppor

8条回答
  •  孤城傲影
    2020-12-24 11:48

    backBarButtonItem leftBarButtonItem and rightBarButtonItem are UINavigationItem objects. There is no style property in UINavigationItem so this is the reason of the warning. You should set the barButtons programatically:

    iOS 4:  

    UIButton *bt=[UIButton buttonWithType:UIButtonTypeRoundedRect];
     [bt setFrame:YourFrame];
     //[bt setImage:[UIImage imageNamed:@"backBT"] forState:UIControlStateNormal];
     [bt addTarget:self action:@selector(popViewController:) forControlEvents:UIControlEventTouchUpInside];
     UIBarButtonItem *leftButton=[[UIBarButtonItem alloc] initWithCustomView:bt];
     self.navigationItem.leftBarButtonItem=leftButton;
    

    For iOS 5+:

    Read the "Customizing Appearance" section of UIBarButtonItem reference.

提交回复
热议问题