我可能在这里做错了,因为这看起来有点愚蠢.
我在我的UINavigationController上设置了一个自定义titleView(以UILabel的形式),在每个页面上都是相同的.为了实现这一点,我在我的app delegate中创建了一个函数来正确显示标签.然后我将其推送到导航堆栈后,在任何子视图上调用此函数.
这是代码(可能比我的解释更有意义):
//In MyAppDelegate.m:
- (void)showTitleForNavigationController:(UINavigationController*) navController {
UILabel *label = [[UILabel alloc] init];
// set up label attributes
// ...
[label sizeToFit]; //without this line my label won't show at all
[navController.navigationBar.topItem setTitleView:label];
[label release];
}
// In SomeViewController.m, when pushing another controller onto the stack:
UIViewController *otherViewController = //initialize other view controller;
[self.navigationController pushViewController:otherViewController animated:YES];
[(MyAppDelegate*)[[UIApplication sharedApplication] delegate] showTitleForNavigationController:otherViewController.navigationController];
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我将下一个视图控制器推入堆栈,并且新控制器平滑地滑动时,在动画的整个持续时间内,标签粘贴在左上方,然后在动画结束后最终捕捉到位.它看起来很奇怪和丑陋.如何正确设置标签,使其从下一个视图平滑滑动?当然,这很简单,我很想念......
在我的应用程序中,我正在实施UINavigationController.有几个UIViewControllers被推入堆栈.
当我到达最后一个时,我希望(在用户操作时)弹出除第一个之外的所有UIViewControllers UIViewController.我怎么做?
我知道如何弹出最后一个,但我如何指示所有以前的那些也消失了?
我需要做一些事情时,我的视图控制器都推或从导航堆栈中弹出,但不希望使用viewillappear/viewdidappear或viewwilldisappear/viewdiddisappear因为这些盖的情况下,除了当视图控制器推/弹出.是正确的方法去使用navigationcontroller委托和navigationController:didShowViewController:animated:和navigationController:willShowViewController:animated:?如果没有,最好的办法是什么?
iphone cocoa-touch uiviewcontroller uinavigationcontroller ios
我在DialogViewController向全局推送应用时遇到问题UINavigationController,它会丢失后退按钮.
我能够把它归结为这个简单的例子:
var nav = new UINavigationController();
window.RootViewController = nav;
nav.PushViewController(new UIViewController() { Title = "#1"}, true);
nav.PushViewController(new DialogViewController(new RootElement("#2")), true);
nav.PushViewController(new UIViewController() { Title = "#3"}, true);
Run Code Online (Sandbox Code Playgroud)
你可以从#3到#2,但不能从#2到#1.
我做错了DialogViewController吗?我虽然可以作为替代品的替代品UIViewController.
我使用以下代码作为扩展UINavigationController来推送具有自定义动画的视图控制器:
@implementation UINavigationController (PushAnimation)
- (void)pushViewController:(UIViewController*)controller withTransition:(UIViewAnimationTransition)transition
{
[UIView beginAnimations:nil context:NULL];
[self pushViewController:controller animated:NO];
[UIView setAnimationDuration:1.0];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
@end
Run Code Online (Sandbox Code Playgroud)
启用缓存后,我在推送时会出现奇怪的动画行为UITableViewController.自定义动画完成后,将显示推送视图的标题.通过过渡风格UIViewAnimationTransitionNone,标题本身就变得清晰.它从屏幕的左上角移动到屏幕的中心UINavigationBar.
禁用缓存后,由于速度不同,此动画不可见,但帧速率显着下降.
如何防止标题动画?
animation objective-c uinavigationcontroller uinavigationitem ios
我怀疑需要清楚..我有堆栈和导航控制器.现在当堆栈加载时viewDidLoad viewWillAppear viewDidAppear将被调用.当我点击一些按钮然后这个按钮把我推到新的堆栈,现在新的堆栈给了我后面的选项..现在当我点击导航控制器的背面viewWillAppear..为什么只会被调用..为什么不viewDidLoad和不viewDidAppear
在我的应用程序中,我需要将以前的viewController标题显示给当前的viewController后标题.
它在iOS6中完美运行.
在iOS7中,自动显示"back"标题,而不是之前的viewController标题.
如何解决iOS7中的问题?
我对iOS Objective-C开发比较陌生,我遇到了一个无法找到解决方案的问题.
我有一个Table View Controller,上面有两个原型细胞,它们很好.这Table View Controller是三选一Tab Views,并且View发送到Tab Views有Navigation Controller.这意味着内部的视图Tab Views也有一个Navigation条.酒吧工作正常,按照预期的"后退"按钮,酒吧就位.但是,(至少在列表视图中)Navigation Bar未完全识别 - 它的标题不会出现,表格单元格直接从状态栏下方开始,而不是在导航栏下方.
这是一些显示问题的屏幕截图:
什么出现在Xcode中(我期望发生什么)
然后在设备上,这是实际出现的 - 后退按钮就位,工作正常,但没有标题字段,表格单元格开始太高.
我已经尝试添加Navigation Bar's了Navigation Items,虽然添加了一个Navigation Item允许我在Xcode中放置标题,但它仍然没有出现在测试设备上.我也尝试Navigation Controller在此视图之前添加另一个,但这也没有解决问题,并且它导致了heirachy中的导航问题.
希望我已经足够清楚了,请说如果我需要发布更多信息 - 我对Xcode比较新,所以不确定究竟什么是适用的,什么不适用.谢谢!
我在嵌入的视图控制器之间有一个自定义推送转换,UINavigationController当使用iOS 7/8构建时它工作正常,但在针对iOS 9 SDK构建时呈现错误的布局.
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
[transitionContext.containerView addSubview:toViewController.view];
...
Run Code Online (Sandbox Code Playgroud)
然后它继续并执行动画.问题是toViewController,即使使用右上方布局指南自动布局约束,内容也会显示导航栏后面的内容.
尽管如此,它在iOS 8上运行正常,如果我们强制重绘(例如,将应用程序发送到后台并将其恢复,在顶部呈现模式并将其解除等)将导致整个自动布局系统重绘并且toViewController视图跳转到正确的位置(作为顶部布局指南,导航栏中的x像素,而不是设备屏幕顶部的x像素).
添加
[self.view setNeedsUpdateConstraints];
[self.view layoutIfNeeded];
Run Code Online (Sandbox Code Playgroud)
如果放入viewDidAppear:animated,但不起作用viewDidLoad或工作viewWillAppear:animated.这不是一个解决方案,因为用户会在重绘时看到视图跳跃viewDidAppear:animated
我正在为iPhone制作iOS应用程序,而我正在使用导航控制器.在导航过程中的某个时刻,我正在向UISegmentedControl导航控制器的导航栏下添加一个视图控制器.我在导航栏中插入新的背景和阴影图像,使其UISegmentedControl显示为导航栏的一部分.我是这样做的:
// nav bar color image
let rect = CGRectMake(0, 0, view.frame.width, 0.5) // Used in navBar, size dosn't matter
UIGraphicsBeginImageContextWithOptions(rect.size, true, 0)
barBackgroundColor.setFill()
UIRectFill(rect)
let navBarBackground = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// setup navbar
navigationController!.navigationBar.setBackgroundImage(navBarBackground, forBarMetrics: .Default)
navigationController!.navigationBar.shadowImage = UIImage()
navigationController!.navigationBar.tintColor = UIColor.blackColor()
navigationController!.navigationBar.translucent = false
Run Code Online (Sandbox Code Playgroud)
当我离开给定的视图控制器时,导航栏背景仍然会改变.
如何恢复导航栏的外观?
要么...
是否有另一种方法嵌入UISegmentedControl扩展的导航栏?
编辑:
在更改背景图像之前的视图控制器中,我尝试保护标准图像:
override func viewDidAppear(animated: Bool) {
if sharedVariables.standartNavBarBackgroundImage == nil {
let herp = navigationController!.navigationBar.backgroundImageForBarMetrics(.Default)
sharedVariables.standartNavBarBackgroundImage = herp
let derp = navigationController!.navigationBar.shadowImage …Run Code Online (Sandbox Code Playgroud) ios ×8
animation ×2
cocoa-touch ×2
iphone ×2
objective-c ×2
c# ×1
ios7 ×1
ios9 ×1
release ×1
swift ×1
titleview ×1
uitabview ×1
view ×1
xamarin.ios ×1
xcode ×1