草庐IT

ViewController3

全部标签

ios - 当中间 viewController 包含两个 viewController 时,UIKeyCommands 不起作用

我认为这是一个与UIKeyCommands、ViewController和/或响应器的层次结构相关的重要问题。在我的iOS9.2应用程序中,我有一个名为NiceViewController的类,它定义了UIKeyCommand,它会导致向控制台打印一些内容。这是NiceViewController:classNiceViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()letcommand=UIKeyCommand(input:"1",modifierFlags:UIKeyModifie

ios - 为什么让 viewController 解雇自己是不好的做法?

我有两个ViewController,MainVC和ModalVC。当用户点击MainVC上的按钮时,模态视图Controller出现。然后用户可以点击另一个按钮将其关闭并返回到主按钮。我试过这两种方法,它们都完成了同样的事情:它们关闭了模态视图Controller://method1://File:ModalVC.swift//@IBActionfuncdismissTapped(){self.dismissViewControllerAnimated(false,completion:nil);}正如我所说的那样工作正常,但考虑另一种方法:使用委托(delegate)让主Contr

ios - 仅在一个 ViewController 中旋转

我正在尝试旋转一个View,而所有其他View(5)都固定为纵向。原因是在那个View中我希望用户观看他之前保存的图片。我想这是可能的,但到目前为止我还不知道如何实现。任何人都可以帮助或给我提示吗?我正在用运行在iOS8上的Swift编程 最佳答案 我建议在您的appDelegate中使用supportedInterfaceOrientationsForWindow以允许仅在该特定ViewController中旋转,例如:swift4/swift5funcapplication(_application:UIApplication,

ios - 在不同的 viewController 中使用相同的 UIWebView

TL;DR:我需要实现一个在多个ViewController之间共享的单例UIWebVIew。这个问题包含了我目前的所有方法。appDelegate:@property(strong,nonatomic)UIWebView*singleWebView;第一个ViewController:@property(weak,nonatomic)IBOutletUIWebView*webView;-(void)viewWillDisappear:(BOOL)animated{[superviewWillDisappear:animated];NSLog(@"Removingwebviewfrom

ios - 在 swift 中关闭模态 viewController 时传递数据

我正在尝试将数据从modalViewController传递到他的sourceViewController。我想我必须使用委托(delegate),但它不起作用。protocolcommunicationControllerCamera{funcbackFromCamera()}classCamera:UIViewController{vardelegate:communicationControllerCamerainit(){self.delegate.backFromCamera()}}classSceneBuilder:UIViewController,communicatio

ios - 转换后关闭 ViewController 以释放内存

我想释放我的ViewController在关闭它后使用的内存。我使用以下代码来呈现新的ViewController并关闭旧的:letsB:UIStoryboard=UIStoryboard(name:"Main",bundle:nil)letnewVC:UIViewController=sB.instantiateViewController(withIdentifier:"MyVC")self.present(newVC,animated:true,completion:{xinoldVC.dismiss(animated:false,completion:{_in//oldVC:v

ios - 如何删除以前的 ViewController

我是一名学生,对编程还很陌生。我正在尝试在业余时间学习Objective-C/Swift。我使用spriteKit和swift制作了一个具有多个菜单/场景的游戏。我正在尝试从一个ViewController过渡到另一个。为此,我使用了这段代码:@IBActionfuncPlayButtonPressed(sender:AnyObject){letplayStoryboard:UIStoryboard=UIStoryboard(name:"Main",bundle:nil)letvc:UIViewController=playStoryboard.instantiateViewContr

ios - 快速以编程方式打开 viewController

我想通过代码在按钮上打开新的UIViewController。我已经在Storyboard中制作了Controller,只想链接它,而且我不想使用XIB接口(interface)或nibName? 最佳答案 要打开新的ViewController,你需要在按钮点击事件中写下这一行:self.performSegueWithIdentifier("GoToViewController",sender:self)要链接新的ViewController,请按照以下步骤操作:从Storyboard中选择新建ViewController并右键

ios - 如何在半屏上呈现 ViewController

我有一个UIViewController,它只有一个UIView,它从底部覆盖了1/3的viewController。像这样我想在另一个ViewController上显示这个viewController。它应该从底部动画出现,并且应该消失到底部动画。但我不希望它覆盖整个屏幕。显示它的viewController应该在后面可见。这似乎是一个基本问题,但我无法完成它。有人可以给我指个方向吗?编辑:这是我迄今为止尝试过的。我创建了这些类//MARK:-classMyFadeInFadeOutTransitioning:NSObject,UIViewControllerTransitionin

ios - 在 ViewController 之外显示 UIAlertController

我无法显示我的UIAlertController,因为我试图在一个不是ViewController的类中显示它。我已经尝试添加它了:varalertController=UIAlertController(title:"Title",message:"Message",preferredStyle:.Alert)UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController,animated:true,completion:nil)哪个不工作..