UINavigationController does not return UINavigationBar elements

I had a problem when my UINavigationBar does not push it when the UINavigationController returns a view controller.

I looked at the stacks, noting the following:

  • The expected number of distributed dispatchers (checked in tools)
  • The stack has the correct number of controllers. (debug logging)
  • Navigation items are not displayed. (debug logging)

Here is what I did.

I pulled some log statements into the viewDidLoad method after calling super.

NSLog(@"%@", [self navigationController]);
NSLog(@"%@", [[self navigationController] viewControllers]);
NSLog(@"%@", [[self navigationController] navigationBar]);
NSLog(@"%@", [[[self navigationController] navigationBar] items]);

After loading the initial view.

2009-10-09 16:42:51.706 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:42:51.720 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>
)
2009-10-09 16:42:51.742 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:42:51.758 Bob[11657:207] (
    <UINavigationItem: 0x242d60>
)

Everything looks good. Press the second controller.

2009-10-09 16:43:11.800 Bob[11657:207] -[MediaBrowser beginLoading] [Line 261] 
2009-10-09 16:43:12.320 Bob[11657:207] -[MediaBrowser loadingComplete] [Line 269] 
2009-10-09 16:43:12.587 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:43:12.654 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>
)
2009-10-09 16:43:12.685 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:43:12.734 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>
)

Again, nothing unexpected here. Press the third controller.

2009-10-09 16:43:19.934 Bob[11657:207] -[MediaBrowser beginLoading] [Line 261] 
2009-10-09 16:43:20.388 Bob[11657:207] -[MediaBrowser loadingComplete] [Line 269] 
2009-10-09 16:43:20.928 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:43:20.962 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>,
    <MediaBrowser: 0x4027e20>
)
2009-10-09 16:43:21.003 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:43:21.039 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>
)

All is well. Now let's pop the controller

2009-10-09 16:43:26.935 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:43:26.945 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>
)
2009-10-09 16:43:26.964 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:43:26.977 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>
)

. - . , . .

009-10-09 16:44:05.878 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:44:05.908 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>,
    <MediaBrowser: 0x407eb00>
)
2009-10-09 16:44:05.951 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:44:05.996 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>,
    <UINavigationItem: 0x407f280>
)

, . .

2009-10-09 16:44:17.770 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:44:17.776 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>
)
2009-10-09 16:44:17.785 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:44:17.793 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>,
    <UINavigationItem: 0x407f280>
)

, . , .

. , - //, , , . , , ( navigationItem ) BarItem.

, . , , .

+3
1

.

, , I - .

pop NSMutableArray. . UINavigationBar - NSMutableArray. UIBarItem.

+3

Source: https://habr.com/ru/post/1719689/


All Articles