草庐IT

UiviewController

全部标签

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()中,添加

ios - XIB 的内容未加载

在我的应用程序中,我有一个自定义的UIViewController,它有一个对应的XIB文件。我在XIB文件中创建了几个按钮和标签,并创建了自定义UIViewcontroller的导出。然后我通过通常的方式将这个ViewController推送到导航堆栈上:letchallengeDetails=ChallengeDetails()self.navigationController!.pushViewController(challengeDetails,animated:true)我知道ViewController正在被压入堆栈,因为我将其View的背景颜色设置为红色,而我得到的是一

ios - 在 View Controller 中添加 Spark 粒子 Sprite

我基于spark模板创建了一个.sks粒子发射器。我的应用程序是普通应用程序(不是游戏)。当用户单击一个按钮时,我有一个新的ViewController,它以模态方式显示全屏,这样我就可以模糊背景。在这个模态中,我创建了一个View并给它一个SCNView类,见下图:如何加载粒子.sks文件以在ParticlesView的viewController上执行动画?更新如何在ViewController中加载SceneKit粒子系统? 最佳答案 如@mnuages所述,您可以使用.scnp文件代替.sks,这是一个SceneKit粒子系

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 - 解散第二个 Controller 后如何在第一个 Controller 中调用函数

我有两个UIViewController,当我单击一个按钮时,它会从第一个ViewController转到第二个ViewController。在此之前,我动画了一个UIView以移动到另一个地方。关闭第二个ViewController后,我想将第一个ViewController中的UIView移回原来的位置。但是,当我在关闭第二个ViewController后从第二个ViewController调用一个函数来为第一个ViewController中的UIview设置动画时,它无法获取UIView的属性,也无法对其执行任何操作。我想是因为第一个UIViewController还没有加载。那

ios - 在保持 Tabbar 的同时在 AppDelegate 中打开 ViewController

在我的Xcode项目中,当用户点击通知时,我想首先将它们发送到我的tabBar中的某个项目,然后我想实例化一个ViewController并将一个对象发送到该ViewController。我有将它们发送到我想要的tabBar的代码,但我不知道如何在保持tabBar和导航栏连接到ViewController的同时将它们实例化到ViewController。关于这个的所有答案都要求您更改RootViewController,这让我在调用ViewController时失去与我的tabBar和导航栏的连接。现实生活中的例子:用户收到Instagram通知说“John开始关注你”->用户点击通知