我知道你必须为IOS6使用新的旋转方法,但似乎我写的方法不起作用.
我设置我的plist文件以允许所有旋转但不允许portraitUpsideDown
然后我在appDelegate中有以下内容:
self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window setRootViewController:navController]; //add nav controller to be the root view
Run Code Online (Sandbox Code Playgroud)
然后在我的rootView中,推送到另一个控制器,我有:
WebViewViewController *webController = [[JBWebViewViewController alloc] init];
webController.urlString = urlName;
[self.navigationController pushViewController:webController animated:YES];
Run Code Online (Sandbox Code Playgroud)
在网络控制器中,我有:
#pragma mark - System Rotation Methods
//for any version before 6.0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//only allow landscape
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
/for 6.0+
- (BOOL)shouldAutorotate{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是,在根视图中允许3次旋转,但是当切换到Web视图时(注意我确实推导航,不添加子视图),我只想允许纵向视图.
请有人帮帮我
-------更新----------
我已经创建了自己的UINavigationController的navController子类,我有一个BOOL landscapeModeOn,我可以设置它来告诉自动旋转规格
#pragma mark - System Rotation Methods …Run Code Online (Sandbox Code Playgroud) 我有两个viewControllers,我正在从FirstView导航到SecondView
将SecondView推送到导航控制器.因为我不想要导航栏
要在SecondView中显示,我会执行以下操作
self.navigationController.navigationBar.hidden=YES;
Run Code Online (Sandbox Code Playgroud)
然后我从secondView返回到FirstView,如下所示
[self.navigationController popViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
但是现在导航栏也没有显示在FirstView中,因为我将它隐藏在
SecondView.我在FirstView中尝试以下内容
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
self.navigationController.navigationBar.hidden=NO;
}
Run Code Online (Sandbox Code Playgroud) 
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
Run Code Online (Sandbox Code Playgroud)
它是一个屏幕截图,当它向上转角时会略微显示.
我用这个代码隐藏了视图中的导航栏.但是当视图开始时它会给我效果,就像导航栏一样.
但是,我想删除此效果或仅删除此视图的导航栏.
我正在努力解决ios7/objective-c问题,希望有人能够帮助我.
作为一些背景,我有一个应用程序在io6设备上按预期呈现,但我试图使其符合ios7.
事情变得令人困惑的是,我的代码在iPhone上按预期工作,但它不在iPad上.
从下面的图像中您可以看到状态栏(运营商,时间,电池)在iPhone上呈现预期效果,而不是iPad:
(注意:由于这是我的第一个帖子,我无法直接嵌入图片,对不起).
从编码的角度来看,我已经尝试了以下所示的所有建议:如何在iOS 7中更改状态栏文本颜色,没有任何运气.
我所做的使得App渲染符合预期的是我的AppDeligate中的以下定义.
// News page
newsViewController = [[NewsViewController alloc] init];
newsNavigationController = [[UINavigationController alloc] initWithRootViewController:newsViewController];
newsNavigationController.navigationBar.translucent = NO;
newsNavigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
newsNavigationController.navigationBar.tag = 4013;
Run Code Online (Sandbox Code Playgroud)
现在我认为问题是即使我已经设置了条形样式UIStatusBarStyleLightContent,应该将文本设置为白色,但它不是在iPad上执行此操作.相反,它在黑色上呈现为黑色.
这似乎是这种情况,因为如果我删除该行:
newsNavigationController.navigationBar.translucent = NO;
Run Code Online (Sandbox Code Playgroud)
黑色变为深灰色,载体,日期,电池,可见黑色.我愿意使用深灰色和黑色背景,但状态栏项目需要像iphone一样呈现白色.
有什么建议?
PS我不确定这是否有助于指出正确的方向,但iPad正在使用splitview控制器.
谢谢
我已经包含了一个导航栏(navigationController)的需要与bar viewController的背景相同的色调...现在我有一个问题...在导航栏和视图之间我有一条水平线将它们分开,就像你一样从图片中可以看出..你能告诉我怎样才能删除这条水平黑色并使其更加一致?
我在AppDelegate中试过这个:
[[UINavigationBar appearance] setShadowImage: [[UIImage alloc] init]];
UINavigationController * nav = (UINavigationController *) self.window.rootViewController; nav.navigationBar.translucent = NO;
Run Code Online (Sandbox Code Playgroud)
但我没有得到结果.你能帮我吗?感谢Rory的所有人.

当UINavigationController中前一个UIViewController的文本太长时,UITabBarItem显示"Back"
在我的应用程序中,我允许用户通过以下代码更改语言:
[[NSUserDefaults standardUserDefaults] setObject:locale forKey:@"locale"];
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:locale, nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
Run Code Online (Sandbox Code Playgroud)
locale将是"en"或"es"等.
我还在后台文本中添加了可本地化的文件.我看到当用户打开应用程序时,它会根据可本地化文件中的文本显示"返回".但是如果用户使用上面的代码更改语言,他将需要重新启动应用程序以使AppleLanguages包中的更改生效.
我还需要UIPickerController上的文本,例如Remove
如何修复以便用户在设置区域设置后无需重新启动应用程序?
我正在练习带导航栏的应用程序.我使用UIBarButton从主屏幕转到下一个屏幕.
UIButton *moveLeft = [UIButton buttonWithType:UIButtonTypeCustom];
[moveLeft setTitle:@"Next Screen" forState:UIControlStateNormal];
moveLeft.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
[moveLeft.layer setCornerRadius:4.0f];
[moveLeft.layer setBorderWidth:1.0f];
[moveLeft.layer setBorderColor: [[UIColor redColor] CGColor]];
moveLeft.frame=CGRectMake(200, 100.0, 90.0, 30.0);
[moveLeft setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
[moveLeft addTarget:self action:@selector(moveToNext) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* barbutton= [[UIBarButtonItem alloc] initWithCustomView:moveLeft];
self.navigationItem.rightBarButtonItem = barbutton;
Run Code Online (Sandbox Code Playgroud)
但现在当第二个屏幕出现时,没有导航栏.以下是该应用的屏幕截图


我也尝试了UIBarButton,但第二个屏幕上仍然没有导航栏.
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
[[self navigationItem] setBackBarButtonItem:back];
Run Code Online (Sandbox Code Playgroud)
我的问题如何在第二个屏幕上显示后退按钮?我没有制作任何自定义按钮,但默认也不会自动进入.请指导我.
问题:我想在像Whatsapp(<Chats(2)/ <Chats(3))这样的弹出视图控制器中自定义导航后退按钮标题。
但是,如果在弹出的视图控制器中分配新的backBarButtonItem,则会禁用向后滑动手势
self.navigationController.interactivePopGestureRecognizer.delegate = self;
Run Code Online (Sandbox Code Playgroud)
要保持手势正常工作,它将给您带来更多麻烦(麻烦太多了)。
嗨,我正在开发一个我应该去的应用程序:
UIViewController1到UIViewController2UIViewController2到UIViewController3UIViewController3到UIViewController4UIViewController4回到UIViewController2我在用UINavigationController.当我使用[self.navigationController pushViewController:VC2 animated:NO];,[self.navigationController popViewControllerAnimated:NO];一切正常.
但是当我使用[self.navigationController popToViewController:VC2 animated:NO];从UIViewController4应用程序终止说法Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'
以下是我的代码如何弹出UIViewController2
for (UIViewController *vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:[ViewController2 class]]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
ViewController2 *VC2 = …Run Code Online (Sandbox Code Playgroud) uiviewcontroller uinavigationcontroller ios poptoviewcontroller
我有两个视图控制器,其中一个通过standard推动另一个UINavigationController。第二个视图控制器通过隐藏其导航栏navigationBarHidden。隐藏该栏似乎阻止了交互式弹出手势识别器的工作。我在第二个屏幕中有一个自定义的后退按钮,因此从所有意图和目的来看,它看起来都非常像导航栏,仅透明等。
有没有一种方法可以重新启用交互式弹出窗口,同时仍将导航栏隐藏在第二个视图控制器上,而在第一个视图控制器上显示呢?我承认我不太确定过渡会是什么,只是想知道这是否有一个简单的解决方案。
ios ×6
objective-c ×5
ios7 ×4
iphone ×4
cocoa-touch ×1
ios6 ×1
localization ×1
rotation ×1
xcode5 ×1