UIBarButton不会在我的UINavigationController中显示

原学程将引见UIBarButton没有会在我的UINavigationController中显示的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。

UIBarButton不会在我的UINavigationController中显示 教程 第1张

成绩描写

我想创立1个戴有导航栏以及表望图的简略望图。所以我创立了UINavigationController的1身材类,并在个中添减了1个UITableView。我的IS也是UITableViewDataSource以及UITableViewDelegate。如今我想在导航栏中添减UIBarButton,但是它没有起感化:

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:[[Translator instance] getTranslation:@"Back"] 
style:UIBarButtonItemStylePlain 
  target:self.parentViewController  action:@selector(dismissFiltersModal:)]; 
self.navigationItem.backBarButtonItem = anotherButton;

出有毛病天显示了望图,但是出有显示按钮。我怎样能力显示它?

推举谜底

jafar,

正如Apple文档修议您应防止子类UINavigationController

此类不消于子类化。

说到这里,您不妨遵守这些简略的步调(给您的1些修议):

    创立扩大UIViewController的掌握器(好比MyController),并在此处添减表格。将您的掌握器树立为该表的署理以及数据源。假如您是由XIB创立的,则须要为您的表望图供给插座。

[P.S。您借不妨子类化aUITableViewController,它有本身的表望图]

    MyControllerviewDidLoad中自界说导航栏。

比方

UIBarButtonItem* myButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(someSelector)];
self.navigationItem.leftBarButtonItem = myButton;

您借不妨自界说题目。

比方

self.title = @"Your custom title";

    在代码中的某个地位创立UINavigationController,并将MyController的虚例添减为根望图掌握器。

比方:

MyController* myCtr = // alloc-init here
UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:myCtr];

佳了闭于UIBarButton没有会在我的UINavigationController中显示的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。