草庐IT

ViewController1

全部标签

Swift - 将 ViewController 插入会出现黑屏

所以我有一个包含tableView的ViewController。每当单击tableview单元格时,都会插入另一个ViewController。这个新的ViewController有自己的xib。文件和快速文件。我在新的ViewController中有一个mapview,但是新的ViewController在插入时是黑色的。我该如何解决这个问题?TableViewdidSelectRowAtIndexPath方法:functableView(tableView:UITableView,didSelectRowAtIndexPathindexPath:NSIndexPath){varc

xcode - 执行从 Xib 到 ViewController 的转场

我有一个带有按钮的Xib文件。单击按钮时,我想转到另一个ViewController。我在StoryBoard中的ViewController之间创建了一个segue并创建了一个标识符,但似乎无法以编程方式调用它。@IBActionfuncbuttonAction(sender:UIButton){self.performSegueWithIdentifier("SegueToPostDetail",sender:sender)}Xcode错误是“....没有成员‘performSequeWithIdentifier’谢谢! 最佳答案

ios - 通过快速单击 TableView 单元格转到 ViewController

有一个类MenuViewController,里面记录了表格中记录的数组:importFoundationimportUIKitclassMenuViewController:UIViewController,UITableViewDelegate,UITableViewDataSource{@IBOutletweakvarmenuTableView:UITableView!letmyTitle=["Помощь","Информация","Поддержка"]overridefuncviewDidLoad(){super.viewDidLoad()menuTableView.de

macos - 如何在 Swift 的 AppDelegate 中使用自己的 ViewController 打开一个新窗口

我制作了一个带有下拉菜单的statusBar应用程序。我想从该下拉菜单中打开一个设置窗口。我用自己的ViewController制作了设置窗口。问题是我不知道如何实例化和显示我创建的settingsWindow。我尝试关注互联网上的每一个话题,但都没有成功。我的ViewController:classSettingsViewController:NSViewController{@IBOutletvaripAddress:NSTextField!@IBOutletvarport:NSTextField!@IBActionfuncconnect(sender:AnyObject){}ov

ios - swift ios - 如何从 AppDelegate 在 ViewController 中运行函数

我正在尝试使用AppDelegate在某些ViewController中运行一个函数funcapplicationDidBecomeActive(_application:UIApplication){ViewController().grabData()}但不知何故,当应用程序从后台进入应用程序后变为事件状态时,该功能似乎根本没有运行。函数看起来像这样funcgrabData(){self._DATASERVICE_GET_STATS(completion:{(int)->()inifint==0{print("Nothing")}else{print(int)for(_,data)

ios - 通过导航 Controller 推送 Viewcontroller,显示黑屏

我在堆栈溢出中搜索这个问题,但无法得到问题的确切答案,我被困了很长时间。我的问题是我试图通过导航Controller推送TestViewController。当我单击按钮时,TestViewController正在加载导航栏并且UIScreen为黑色。TestViewController代码importUIKitclassTestViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview.}overridefu

ios - 为什么从 ViewController 转到 TableViewController 时我会不断收到此错误?

我的viewController中有这个按钮,当我按下它时,它应该转到TableViewController。当我这样做时,应用程序崩溃并在控制台中打印此错误。有人能告诉我我做错了什么吗?谢谢!Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'-[UITableViewControllerloadView]instantiatedviewcontrollerwithidentifier"UIViewController-iLh-Fe-Ezq"fromstoryboard"Main

ios - 如何使用 Swift 在 ios 中关闭 viewController

我有一个viewController,它只包含一个imageview。我想在应用程序加载时显示它,例如从Web服务获取数据。所以我在我的loaderViewController中创建了一个函数funcshowLoading(viewController:UIViewController){viewController.presentViewController(LoadingViewController(),animated:false,completion:nil)}这是按预期工作的,当我在需要时调用此函数时如下所示varloader=LoadingViewController()l

ios - 添加 ViewController.swift 并重命名后,它不会将我的 viewController 与那个 swift 类链接起来

我创建了新的swift文件myviewController.swift,在链接到我的ViewController之前,我将它重命名为newController.swift。然而,它没有在身份检查器中显示将类链接到我的ViewController。我尝试将它直接添加到项目文件夹,但它说newController.swift文件已经存在。任何人都可以提出问题所在吗? 最佳答案 InterfaceBuilder中填充的类列表基于类名而不是文件名。单个文件可以包含多个类。除了更改文件名外,如果您希望类名在InterfaceBuilder和其

swift - 从 appdelegate 更新 viewcontroller - 最佳实践?

我正在尝试在AppDelegate.swift中实现CoreLocation方法的iBeacons(方法在AppDelegate中实现以确保应用程序后台功能)在“ViewController.swift”附带的SingleView应用程序中,将数据从AppDelegate传递到ViewController以更新View(例如UIImages、UILabels或UITableViews)的最佳做法是什么?我已经成功实现了两种不同的方法:1)委托(delegate),通过在AppDelegate.swift中触发Viewcontroller委托(delegate)方法:protocolBe