草庐IT

UIViewController_keyboard

全部标签

swift - 无法将 UIViewController 类型的值转换为 RecordDrawerController

我已经复制了一个目标和它的模式,我正在尝试运行该项目,但由于我不知道的任何原因它失败了。在下面我粘贴了错误的捕获。有什么帮助吗? 最佳答案 CouldnotcastvalueoftypeUIViewControllertoRecordDrawerController选择适当ViewController的顶部黄色按钮,然后转到Utilities->IdentityInspector->CustomClass->Class然后将适当的ViewController自定义类更改为RecordDrawerController。

ios - 在启动期间将 UIViewController 设置为 UIWindow 的根时,不会调用 viewWillAppear 和以后的生命周期事件

我的application(_:didFinishLaunchingWithOptions:)方法中有以下代码self.window=self.window??UIWindow()self.window?.makeKeyAndVisible()letmainViewController=HomeViewController.instantiate()//hereIjustcalltheviewControllerthroughstoryboard,setsomepropertiesandreturnitsinstancewindow?.rootViewController=mainVi

swift - 如何设置 UIViewController 背景图像以填充屏幕

我有一个UIViewController,我想将背景设置为一张图片。我想在代码中执行此操作而不是IB,因此我可以随后更改图像。阅读了此处有关.ScaleAspectFill的所有提示后,我的图像仍然无法调整大小以适合屏幕。任何人都可以提供任何建议吗?我的代码是:overridefuncviewDidLoad(){super.viewDidLoad()//settheinitalbackgroundColorself.view.backgroundColor=UIColor(patternImage:gameBackgroundOne!)self.view.contentMode=UIV

ios - 将自定义 UITableViewCell 从 nib 加载到 Swift 中的 UIViewController

我目前正在开发一个练习swift程序,该程序需要将CoreData结果显示在表格上。我已经构建了我的应用程序,Storyboard本身不包含任何UI元素,仅包含View(带有随附的UIViewController类),然后加载自定义nibs/xibs(也随附UIView的子类)。在这种情况下,xib包含一个UITableView,一个单独的xib包含单元格。TableView类:importUIKitprotocolSkillsViewDelegate{}classSkillsView:UIView{vardelegate:SkillsViewDelegate!@IBOutletwea

ios - 如何在 iPhone 上以编程方式在 Swift 中将 UIViewController 呈现为弹出窗口

通常我遵循这里的说明:https://stackoverflow.com/a/24687152/3741933.但是,正如其评论中所讨论的,无论preferredContentSize还是sourceRect,弹出窗口始终是全屏的。显示弹出窗口的按钮:funcbuttonClicked(sender:UIButton!){letac=EmptyViewController()asUIViewControllerac.modalPresentationStyle=.Popoverac.preferredContentSize=CGSizeMake(200,200)letpopover=a

ios - 如何检查当前的 UIViewController 是否是 UINavigationController 的一部分

在我的应用程序中,UIViewController“ProfilVC”是UINavigationController“nav”的一部分。但在另一个场景中,我呈现“ProfilVC”以重用相同的UIViewController,但使用不同的数据。letvc=tweetsStb.instantiateViewController(withIdentifier:"ProfilVC")as!ProfilVCself.present(vc,animated:true,completion:nil)在didSelectRowAt中,我展示了另一个UIViewController。在这里,我需要检查

ios - 如何访问 "func applicationWillResignActive"内的 UIViewController 变量? swift ,iOS Xcode

我的UIViewController类设置如下:classViewController:UIViewController{varcurrentTask:NSURLSessionTask?...}如果用户按下主页按钮,我想做self.currentTask.cancel()但是我如何从AppDelegate.swift访问这个变量呢?funcapplicationWillResignActive(application:UIApplication){} 最佳答案 在UIViewController类的viewDidLoad()中,添加

xcode - 无法将 UITableViewDataSouce 和 UITableViewDelegate 设置为 UIViewController

当我尝试将委托(delegate)和数据源设置为UIViewController时,所有在UITableViewController中正常运行的函数都被检测为错误。funcnumberOfSectionsInTableView(tableView:UITableView!)->Int{//#warningPotentiallyincompletemethodimplementation.//Returnthenumberofsections.return1}functableView(tableView:UITableView!,numberOfRowsInSectionsection

ios - 我可以快速为 UIViewController 而不是 UITableViewController 创建拉动刷新吗?

我有一个简单的应用程序,无需使用UITableViewController构建。是否有机会为简单的UIViewController创建“拉动刷新”功能? 最佳答案 是的,有。事实上,要使用UIRefreshControl只有一个要求-您可以将UIRefreshControl放在UIScrollView或其子类中(例如UITableView或UICollectionView)。Swift中的示例代码:overridefuncviewDidLoad(){{super.viewDidLoad()//...letrefreshControl

ios - Swift:来自 UIViewController 扩展的 registerForKeyboardNotifications

我正在尝试清理我的代码并创建和扩展UIViewController以注册和取消注册我的键盘。在我的实用程序文件中,我有以下内容:extensionUIViewController{//RegisterthekeyboardfornotificationsinviewDidLoadfuncregisterForKeyboardNotifications(){//AddingnotifiesonkeyboardappearingNSNotificationCenter.defaultCenter().addObserver(self,selector:#selector(CreateEve