有没有办法让UIViewController(在导航堆栈内)检测它是否因为执行了向下钻取或向下钻取而出现?
在viewWillAppear中,遗憾的是UINavigationController的topViewController和visibleViewController已经设置为新的ViewController.
我有一个使用两个UINavigationControllers的应用程序 - 一个用于菜单系统,另一个用于实际游戏.在我的appDelegate中声明了一个常见的UINavigationController.当应用加载时,它会加载菜单或游戏的UINavigationController.当然,玩家可以在两者之间导航.
从菜单到游戏时,我创建了一个新的UINavigationController,并按如下方式呈现:
GameViewController *rootController = [[GameViewController alloc] init];
UINavigationController *newNavController = [[UINavigationController alloc] initWithRootViewController:rootController];
[rootController release];
newNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newNavController animated:YES];
[newNavController release];
Run Code Online (Sandbox Code Playgroud)
但是,我注意到当我这样做时,Menu的viewController从不调用dealloc.大概是因为仍然有人提到让它保持活力的东西.我发现当我明确地将App Delegate的UINavigationController设置为新的导航控制器时(在释放新的navController之前),它会释放菜单.我这样做如下:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.navController = newNavController;
[newNavController release];
Run Code Online (Sandbox Code Playgroud)
这是好习惯吗?我发现当从游戏导航回菜单时,同样的技巧似乎不起作用.即
MainMenuViewController *menuViewController = [[MainMenuViewController alloc] init];
UINavigationController *newNavController = [[UINavigationController alloc] initWithRootViewController:menuViewController];
[menuViewController release];
newNavController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:newNavController animated:YES];
//Setting the appDelegate's navController to the new navController allows the menu to dealloc.
//This must happen AFTER the newNavController …Run Code Online (Sandbox Code Playgroud) iphone delegates memory-management objective-c uinavigationcontroller
我有一个加载视图的视图,需要将视图推送到主导航控制器.
我为每个视图设置了一个委托,基本上让我的呼叫备份到主导航控制器的"链".
它有效,但我很好奇是否有更好(更容易?)的方法来实现这一目标?
我想知道是否可以使用导航控制器按钮返回上一页2.现在,我已经使用此代码自定义按钮
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:mainLib.navCountryTitle
style:UIBarButtonItemStyleBordered
target:self
action:@selector(handleBack:)];
Run Code Online (Sandbox Code Playgroud)
在'回调'方法上,我称这行
[self.navigationController popViewControllerAnimated:YES];
所以在这种情况下,它将转到上一个屏幕.但是我想在上一个屏幕之前进入屏幕.
我知道我可以直接调用那个屏幕,但我不想这样做,因为在每个屏幕上我都有一个后退按钮,它应该转到之前的屏幕.
back-button back uinavigationbar uinavigationcontroller uinavigationitem
是的,我已经找到了答案.除了没有提供淡入淡出过渡选项,只有翻转或卷曲的解决方案之外,这些解决方案都不起作用.
像这样:
methodname
configure animation
[self.navigationController popViewControllerAnimated:NO];
Run Code Online (Sandbox Code Playgroud)
无论我尝试什么样的过渡动画配置,没有什么明显不同于仅使用典型的单行流行音乐.如果我改成它…Animated:YES];,我会得到标准的流行动画,也许是从破坏的配置中发生了一些奇怪的事情.
所以我的问题是这样的:pop如果不是CrossDissolve,那我怎么能用,然后至少看起来相同的东西呢?甚至可以使用导航控制器吗?
使用模态视图将具有我想要的默认动画,并且我可以轻松地管理视图堆栈,但我不想这样做.
我正在尝试在UITabBar.viewControllers数组中选择一个UINavigationControllers.
我之前尝试过设置UITabbarController.selectedIndex,但Apple文档说: "要选择更多导航控制器本身,您必须改为改变selectedViewController属性的值."
AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
UINavigationController *navController = [appDelegate.objTabBarController.viewControllers objectAtIndex:5];
[appDelegate.objTabBarController setSelectedViewController:navController];
Run Code Online (Sandbox Code Playgroud)
这样做很好但是当我改回到MoreViewController的列表视图时,左侧的图标消失了,不会再回来.
一切都好,用手指选择它.

以编程方式选择时出现错误 - >图像消失了

我有什么错误吗?
最好的问候,史蒂夫
我对导航控制器的后退按钮动画有一个奇怪的问题:
我的应用程序有一个带有3个选项卡的标签栏控件,其中一个带有两个后续视图控制器的导航控制器,第一个只显示一个主表,第二个显示详细信息,当我从详细信息中点击后退按钮时出现问题视图控制器,而不是滑回主视图控制器,它只是弹出视图而不动画.
我注意到,如果我先转到另一个标签,然后再返回到此标签,动画将正常触发.
我从头开始重建整个应用程序导航,但问题仍然存在,任何帮助都表示赞赏.
提前致谢!.
编辑:添加了更多信息
这就是我的故事板在该特定分支中的样子:

这是来自"Partidos Activos"视图控制器的prepareForSegue:
#pragma mark - Segues
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"PartidosEnDia"]) {
PartidosActivosEnFecha *paf = segue.destinationViewController;
CalendarCell *senderCell = (CalendarCell *)sender;
paf.datos = senderCell.dataDic;
}
}
Run Code Online (Sandbox Code Playgroud)
两个viewController viewDidLoad方法都在方法的开头调用super.
正如我之前所说,如果我只是点击其他选项卡然后再回到这一个,那么来自"Partidos Activos En Fecha"viewController的幻灯片动画按预期工作,只有当我启动应用程序并直接转到此viewController时回滚动画不起作用,它只是在没有动画的情况下进入调用者viewController.
希望我添加足够的信息,如果不是只是告诉我,我会再次添加它.
我正试图在我的应用程序中显示一个简单的设置屏幕,我正在使用Autolayout.由于我的应用程序支持横向,并且当手机处于横向状态时设置控件不完全适合垂直,我添加了UIScrollview.
似乎UIScrollview和Autolayout的组合在这里和其他地方是一个常见的问题.我已经阅读了一些关于它的文章,从它可以看出,似乎一个好的方法去做我想要做的是将我的各种控件放在一个视图中,就像一个带有约束的"contentView"在该视图中对齐.然后让contentView成为UIScrollView的唯一子视图.我有contentView的约束绑定到UIScrollView的边缘.
UINavigationView -> UIScrollview -> contentView (UIView) -> Control Subviews
Run Code Online (Sandbox Code Playgroud)

它在纵向工作正常,即使我在contentView中添加需要滚动查看的内容,但是当我去景观时,它不会让我向下滚动得足够远.这就像我旋转时内容大小重置为可见区域(或导航控制器superview的框架)的框架.

我想知道我是否需要检查旋转,然后再次设置内容大小?如果是这样,有没有办法从视图(contentView)动态获取该大小?
谢谢你尽你所能的帮助!吉姆
我是新手,但我想我已经掌握了它.这让我的进步很难过.
我想要做的是当我们无法找到他的查询的相关数据时向用户抛出错误消息,然后继续将他带回到之前的ViewController.
但是,我在这方面遇到了麻烦.在我添加操作的行上,我收到以下错误:'UIViewController?' 不是Void的子类型
let alertController = UIAlertController(title: "Oops", message: "We couldn't find any data for this title, sorry!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { action in
self.navigationController?.popViewControllerAnimated(true)
}))
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?我错过了一些明显的东西吗 我试着搞砸了被弃用的UIAlertView,但却没有变得更聪明.
我想将右栏按钮项的颜色从黑色更改为白色.它是一个按钮作为搜索图标.我还没有对搜索实现进行编码,因为我想首先完成主界面.我以为我写了正确的代码所以它应该显示为白色,但它在故事板和模拟器中似乎仍然显示为黑色.
在故事板中,我还将其设置为白色.
这是我的代码,它位于AppDelegate.swift文件中:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Changing the status bar's colour to white
UIApplication.sharedApplication().statusBarStyle = .LightContent
// Changing the navigation controller's background colour
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green: 165.0/255.0, blue: 227.0/255.0, alpha: 1.0)
// Changing the navigation controller's title colour
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
// Changing the colour of the bar button items
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
// Changing the tint colour of the tab bar icons
UITabBar.appearance().tintColor = UIColor(red: 0.0/255/0, …Run Code Online (Sandbox Code Playgroud) uinavigationbar uinavigationcontroller uinavigationitem ios swift
ios ×5
iphone ×3
xcode ×3
delegates ×2
objective-c ×2
swift ×2
animation ×1
autolayout ×1
back ×1
back-button ×1
image ×1
transition ×1
uiscrollview ×1
uitabbar ×1
uiview ×1