我还该怎么办?
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutoRotate
{
return NO;
}
Run Code Online (Sandbox Code Playgroud)
我的viewController仍在旋转.
它嵌入在导航堆栈中.如果我将UINavigationController子类化,并在那里实现相同的仅肖像模板,并将我的viewController嵌入到调整后的navigationController中,而不是它的工作原理,但我无意在UINavigationController出现的任何地方重写我的代码.
这里的最佳做法是什么?
uiviewcontroller uinavigationcontroller uiinterfaceorientation autorotate ios
我知道如何使用以下代码更改UINavigationBar的标题字体属性:
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont boldSystemFontOfSize:16.0f], UITextAttributeFont, nil]];
Run Code Online (Sandbox Code Playgroud)
但是,我发现当我以这种方式更改字体大小时,它会影响所有视图,而不仅仅是我实现上述代码的视图.问题是,我想改变只有2个具有长标题的视图的大小.其他视图(包括根视图)我希望保留字体大小的默认设置.我尝试viewDidLoad使用上面的代码在方法中将字体大小更改回正常,但它不起作用.
有没有办法改变某些视图的标题字体大小?谢谢.
错误不是每次都有.我曾尝试清理和重建应用程序,但它也是.
错误:
*** Assertion failure in -[UIWindowController
transition:fromViewController:toViewController:target:didEndSelector:],
/SourceCache/UIKit_Sim/UIKit-2372/UIWindowController.m:211
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Attempting to begin a modal transition from
<UINavigationController: 0x9190730> to <UINavigationController: 0x83a9dc0>
while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear
to know the current transition has completed'
*** First throw call stack:
(0x213d012 0x1e85e7e 0x213ce78 0x191bf35 0x10b8d05 0xeb74f3 0xeb7777 0x10be033f
0xeb77b7 0x104f0 0x1e996b0 0x18c6035 0x20c0f3f 0x20c096f 0x20e3734 0x20e2f44
0x20e2e1b 0x36437e3 0x3643668 0xdcd65c 0x1133f2 0x25c5)
libc++abi.dylib: terminate called throwing an exception …Run Code Online (Sandbox Code Playgroud) 有没有办法在我的整个应用程序中覆盖我的所有视图控制器中的viewWillDisappear(或任何视图控制器委托方法)?
为了清楚起见,我仍然想在视图控制器本身中自定义每个viewWillDisappear方法,但基本上我想为每个视图控制器的viewWillDisappear方法添加一行代码,而不必手动执行(这是一个大项目).
我创建了一个带有串行视图的应用程序(A,B,C,D,...),我需要将D弹回到B.有人可能会说为什么不使用:
[self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:1] animated:YES];
Run Code Online (Sandbox Code Playgroud)
但是,这不是一个好的解决方案.因为这个方法需要你得到我们"B"存储的索引.
问题:如何在viewControllers中获取"B"的索引?
格式UIViewControllers应为:
"<A:0x6e70710>","<C:0x6e30370>","<B:0x6988a70>","<D:0x6ea8950>","<E:0x6eaaad0>"
我已经尝试过并且未能使用rangeOfString并hasPrefix获得"B"视图的索引.
我正在尝试将图像用作导航栏中的按钮.按钮显示正常,但它们不响应触摸事件.这是我设置按钮的方式:
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_up_24.png"]];
iv.userInteractionEnabled=YES;
UIBarButtonItem * logoutButton = [[UIBarButtonItem alloc] initWithCustomView:iv ];
logoutButton.target=self;
logoutButton.action=@selector(logoutButtonPressed);
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
iphone uiimageview uinavigationcontroller uibarbuttonitem ios
目前,我在一个单独的故事板中有一个导航控制器,可以使用退出按钮.这个退出按钮应该回到rootViewController(那是在mainstoryboard中)这是一个iSplitViewController ......
我无法找出正确的Segue命令来完成这项工作
uinavigationcontroller uisplitviewcontroller uistoryboard uistoryboardsegue
[[[UINavigationBar appearance] setTitleView:button]
Run Code Online (Sandbox Code Playgroud)
我尝试使用上面的代码行将标题视图设置为所有导航项的按钮,但它不起作用.如何通过在appdelegate中编写小代码来为项目中的所有导航栏设置标题视图?
iphone objective-c uinavigationbar uinavigationcontroller ios
我正在开发一个应用程序,它本质上是许多不同测试的序列(为简单起见,考虑SAT测试或Mensa测试).每个测试都在不同的View + View Controller中实现.
最初我想使用Storyboards和UINavigationControllers来管理测试的顺序和它们之间的转换,但现在我质疑这种方法的有效性.UINavigationController是一个堆栈,而我的导航只是单向的(一旦你完成了一个你不能回去的测试).有没有更好的方法来实现应用程序?我还能以某种方式利用故事板吗?
我有一个自定义的png我设置为UINavigationBar的后退按钮,如下所示:
UIImage *navBackgroundPortait = [[UIImage imageNamed:@"nav_bg_portrait.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundPortait forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
在viewDidLoad方法的视图控制器中,我使用此hack来显示没有标题/文本的后退按钮:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStyleBordered target:nil action:nil];
Run Code Online (Sandbox Code Playgroud)
但我的后退按钮png在宽度上拉伸,我真的希望它根本不这样做.我只是想在所有视图上显示一个静态png图像作为我的后退按钮,上面没有任何文字,并且永远不会拉伸它.我可以这样做,我该怎么办?
最好的问候
Søren