更新:我已决定针对我的问题采取不同的路线.我没有尝试直接重用相同的UIViewController,而是使用两个设置为rootViewControllers的 vanilla UIViewControllers.在他们的loadView方法中,他们调用获取前UIViewController并将其视图设置为控制器的视图.这可能是首选的方法,因为我需要设置几个变量和委托.[storyboard instantiateViewControllerWithIdentifier:]
我有一个带有UITabBarController的UIStoryBoard作为与两个UINavigationControllers连接的入口点.每个人共享一个共同的UIViewController作为他们的根视图控制器.应用程序启动时,将选择第一个UITabBarItem,并按预期加载视图.但是,当我选择第二个UITabBarItem时,同一视图不可见.我看到UINavigationBar有黑色背景.我在使用Storyboard界面做错了什么,或者我是否需要通过每个UINavigationController的方法手动实例化UIViewController - 例如loadView?
uitabbarcontroller uiviewcontroller uinavigationcontroller ios uistoryboard
我正在使用此代码
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)])
{
[self presentViewController:navigationControllerCustom animated:YES completion:nil];
}
else
{
[self presentModalViewController:navigationControllerCustom animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序有两个方向纵向和纵向颠倒.此代码适用于iOS 5.1,但方向在iOS 6上不起作用
我也在navigationControllerCustom课上添加了这段代码
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题.
提前致谢.
这可能吗?
我想在视图控制器中更改导航栏的alpha值(在动画中),但是如果我这样做self.navigationController.navigationBar.alpha = 0.0;,导航栏占用的屏幕部分完全消失并留下一个黑盒子,这不是我想要的喜欢(我更喜欢它是self.view背景的颜色).
objective-c uinavigationbar uiview uinavigationcontroller ios
你们有没有在这个问题上跌跌撞撞?
基本上在iOS 7中,导航控制器在我导航到的子视图上呈现.
在iOS 6视图中,我导航到导航栏和页脚之间.在iOS 7中,它看起来像子视图在导航栏和页脚下全屏显示.结果用户看不到它.
以下是我导航到子视图的方法
BRSMyListSubViewController *tagsInfoVC = [[BRSMyListSubViewController alloc] initWithCheckinsList:self.checkinsList
selectedTag:[self tagByIndexPath:indexPath]];
[self.navigationController pushViewController:tagsInfoVC animated:YES];
Run Code Online (Sandbox Code Playgroud)
这是我如何初始化它 viewDidLoad
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(settings:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(logout:)];
Run Code Online (Sandbox Code Playgroud)
对于它的价值,我还应该提到子视图是使用Autolayout在XIB中定义的.这是我的XIB的来源:http://pastebin.com/6RR0zYu4
最后,这是它在iOS 6中的外观

在iOS 7中

有什么想法吗 ?
我希望在我推出一个视图控制器后,我需要释放我对视图控制器的所有权,就像我在下面所做的那样.
CustomViewController *nextViewController = [[CustomViewController alloc] initWithNibName:@"CustomView" bundle:nil];
[[self navigationController] pushViewController:nextViewController animated:YES];
[nextViewController release];
Run Code Online (Sandbox Code Playgroud)
在我这样做之后,我假设导航控制器拥有该对象的所有权,并在完成时将其释放,然后在我的customViewController上调用dealloc.当我点击导航栏上的后退按钮并且不再显示视图时,我希望会发生这种情况.但这不会发生.我在一个CustomViewController的dealloc方法中添加了一个NSLog(@"CustomViewController确实收到了dealloc"),但它永远不会被打印出来.这是正常的行为吗?
导航控制器是否只是在保留该对象以防万一在某些时候需要它?当内存开始耗尽时它会摆脱它吗?我尝试模拟低内存警告但没有任何反应.我有一种感觉,这个问题的答案是我不应该太担心并遵循保留/释放/自动释放的标准程序.尽管如此,是否还有其他人深入研究了这一点并找到了绝对答案?
iphone memory-leaks memory-management uiviewcontroller uinavigationcontroller
我有一个导航控制器,它有几个视图控制器.除了一个只支持横向的特殊视图控制器外,我需要支持所有视图控制器的所有方向.此特殊视图控制器显示在导航堆栈的中间.我做了很多研究,但找不到任何好的解决方案.以下是我阅读和尝试过的链接.
如何从纵向模式自动旋转到横向模式? iPhone - 仅在一个视图控制器上允许横向显示 http://goodliffe.blogspot.com/2009/12/iphone-forcing-uiview-to-reorientate.html
接下来我将尝试替换导航控制器presentModalViewController以显示特殊视图控制器.然后我将在特殊视图控制器内创建一个新的导航视图控制器来推送后续的视图控制器.
如果有人有更好的想法,请告诉我.非常感谢!
更新:我已成功地使用我上述方法:更换pushViewController用presentModalViewController,并创建一个新的导航控制器.
iphone cocoa-touch uinavigationcontroller uiinterfaceorientation ios
我有一个UINavigationController,在堆栈上包含3个UIViewControllers.
View A - is the root
View B - is pushed by View A and has `self.navigationItem.hidesBackButton = YES;`
View C - is pushed by View B and has `self.navigationItem.hidesBackButton = NO;`
Run Code Online (Sandbox Code Playgroud)
即使我将hidesBackButton设置为NO,View C也不会显示后退按钮.我该如何解决这个问题?
iphone cocoa-touch objective-c uinavigationcontroller uinavigationitem
我向导航控制器添加自定义按钮
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(backAction)];
self.navigationItem.leftBarButtonItem = backButton;
它工作正常,但按钮出现边框.我该如何解决这个问题?
更新 我找到了解决方案
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
[button setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonFavoriteClicked) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithCustomView:button];
[button release];
self.navigationItem.leftBarButtonItem = back;
Run Code Online (Sandbox Code Playgroud) 这是球场.
viewWillAppear和viewDidAppear我的控制器.那么我应该怎么做以确保无论我的视图层次结构如何都始终调用这两个方法?
"复杂"视图层次结构的示例:
UIViewController subclass containing a UITabBarController
|_ Each tab containing a UINavigationViewController
|_ Each UINavigationController controller containing a custom UIViewController
Run Code Online (Sandbox Code Playgroud)
当您将TabBarController作为模态视图呈现时,将调用TabBarController的方法viewWillAppear和viewDidAppear方法,而不是嵌套在UINavigationViewControllers下的自定义UIViewControllers的方法.
我想重新创建iOS 7/8日历应用程序中显示的搜索UI.以模态方式呈现搜索UI不是问题.我使用UISearchController和模态呈现它就像UICatalog示例代码显示,它给了我一个很好的下拉动画.尝试从结果视图控制器推送视图控制器时出现问题.它没有包裹在导航控制器中,所以我无法推动它.如果我将它包装在导航控制器中,那么当我呈现时,我没有得到默认的下拉动画UISearchController.有任何想法吗?
编辑:我通过将结果视图控制器包装在导航控制器中来推动它.但是,在将新VC推入堆栈后,搜索栏仍然存在.
编辑(2):Apple的DTS表示日历应用程序使用非标准方法从搜索结果中推送.相反,他们建议从搜索控制器中移除焦点,然后将焦点推向并返回pop.这类似于我想象的设置应用程序中的搜索方式.
ios ×8
iphone ×5
cocoa-touch ×3
ios6 ×2
objective-c ×2
ios7 ×1
ios8 ×1
memory-leaks ×1
orientation ×1
uistoryboard ×1
uiview ×1
xcode ×1