我刚试了下,创建类的时候下面没有继承 UINavigationController 的啊!是你自己加的吗?只有创建category下才有。另外你在 AppDelegate.m 里加上
CustomPickerController *customView = [[CustomPickerController alloc] init];
UINavigationController *navCtrol = [[UINavigationController alloc] initWithRootViewController:customView];
self.window.rootViewController = navCtrol;
应该也可以
CustomPickerController *customView = [[CustomPickerController alloc] init];
UINavigationController *navCtrol = [[UINavigationController alloc] initWithRootViewController:customView];
self.window.rootViewController = navCtrol;
应该也可以
设置navigation title的代码不变,还是使用
self.title=@"相册";
或
self.navigationItem.title=@"相册";但在使用你这个自定义的控制器的时候,如果是作为根控制器出现,需要包装成UINavigationController的rootController.
CustomPickerController *customView = [[CustomPickerController alloc] init];
UINavigationController *navCtrol = [[UINavigationController alloc] initWithRootViewController:customView];
self.window.rootViewController = navCtrol;如果不是,而是通过其它控制器导航过来的,就不需要。因为通过其它控制器过来时,已经将控制器压入到控制器栈中。在这个控制器内部需要导航其它控制器的时候,需要这样来用
PhotoDisplayController *photoDisplay = [[PhotoDisplayController alloc] init];
photoDisplay.group = [_assetGroupArr objectAtIndex:indexPath.row];
[self.navigationController pushViewController:photoDisplay animated:YES];
事实上继承navigation,实际上还是需要一个viewcontroller的的。