草庐IT

ViewController2

全部标签

ios - 在 Swift 中从 AppDelegate 获取 ViewController 的实例

当用户单击UILocalNotification时,我正在尝试从appdelegate中快速加载特定的ViewController。我发现这是在这个函数中调用的:funcapplication(application:UIApplication!,didReceiveLocalNotificationnotification:UILocalNotification!)但是当我尝试访问其中一个打开的ViewController时,我认为它返回null,因为我的应用程序崩溃了。这是我正在尝试的:varrootViewController=self.window!.rootViewContr

ios - 在 Swift 中从 AppDelegate 获取 ViewController 的实例

当用户单击UILocalNotification时,我正在尝试从appdelegate中快速加载特定的ViewController。我发现这是在这个函数中调用的:funcapplication(application:UIApplication!,didReceiveLocalNotificationnotification:UILocalNotification!)但是当我尝试访问其中一个打开的ViewController时,我认为它返回null,因为我的应用程序崩溃了。这是我正在尝试的:varrootViewController=self.window!.rootViewContr

ios - 更改 ViewController Swift 的背景颜色? (单 View 应用程序)

我正在使用Swift(XCode6.2)制作一个非常简单的单View应用程序,它包含2个按钮“blackButton”和“whiteButton”。单击blackButton后,它会将View的背景颜色更改为黑色,单击whiteButton后,它会将背景更改为白色。谁能建议任何可能的方法来做到这一点?ViewController.swift://beginningimportUIKitclassViewController:UIViewController{@IBActionfuncblackButton(sender:AnyObject){}@IBActionfuncwhiteBut

ios - 更改 ViewController Swift 的背景颜色? (单 View 应用程序)

我正在使用Swift(XCode6.2)制作一个非常简单的单View应用程序,它包含2个按钮“blackButton”和“whiteButton”。单击blackButton后,它会将View的背景颜色更改为黑色,单击whiteButton后,它会将背景更改为白色。谁能建议任何可能的方法来做到这一点?ViewController.swift://beginningimportUIKitclassViewController:UIViewController{@IBActionfuncblackButton(sender:AnyObject){}@IBActionfuncwhiteBut

uitableview - Swift:将 UITableViewCell 标签传递给新的 ViewController

我有一个UITableView,它根据JSON调用使用数据填充单元格。像这样:varitems=["Loading..."]varindexValue=0//HereisSwiftyJSONcode//for(index,item)inenumerate(json){varindvItem=json[index]["Brand"]["Name"].stringValueself.items.insert(indvItem,atIndex:indexValue)indexValue++}self.tableView.reloadData()如何在单元格被选中时获取单元格的标签,然后将其传

uitableview - Swift:将 UITableViewCell 标签传递给新的 ViewController

我有一个UITableView,它根据JSON调用使用数据填充单元格。像这样:varitems=["Loading..."]varindexValue=0//HereisSwiftyJSONcode//for(index,item)inenumerate(json){varindvItem=json[index]["Brand"]["Name"].stringValueself.items.insert(indvItem,atIndex:indexValue)indexValue++}self.tableView.reloadData()如何在单元格被选中时获取单元格的标签,然后将其传

ios - 在容器 View 中加载 ViewController

我在VC中有一个全屏的containerView。如果我从Storyboard中手动将一个child添加到containerView中,那么嵌入segue看起来不错:但是如果我通过代码嵌入VC:classBannerContainerVC:UIViewController{@IBOutletweakvarcontainer:UIView!overridefuncviewDidLoad(){super.viewDidLoad()letvc=storyboard?.instantiateViewControllerWithIdentifier("test")asUIViewControll

ios - 在容器 View 中加载 ViewController

我在VC中有一个全屏的containerView。如果我从Storyboard中手动将一个child添加到containerView中,那么嵌入segue看起来不错:但是如果我通过代码嵌入VC:classBannerContainerVC:UIViewController{@IBOutletweakvarcontainer:UIView!overridefuncviewDidLoad(){super.viewDidLoad()letvc=storyboard?.instantiateViewControllerWithIdentifier("test")asUIViewControll

ios - 在 Swift 中遵守 ViewController 中的协议(protocol)

尝试在SwiftUIViewController子类中符合UITableViewDataSource和UITableViewDelegate。classGameList:UIViewController{varaTableView:UITableView=UITableView()overridefuncviewDidLoad(){super.viewDidLoad()aTableView.delegate=selfaTableView.dataSource=selfself.view.addSubview(aTableView)//errorsonbothlinesfornotcon

ios - 在 Swift 中遵守 ViewController 中的协议(protocol)

尝试在SwiftUIViewController子类中符合UITableViewDataSource和UITableViewDelegate。classGameList:UIViewController{varaTableView:UITableView=UITableView()overridefuncviewDidLoad(){super.viewDidLoad()aTableView.delegate=selfaTableView.dataSource=selfself.view.addSubview(aTableView)//errorsonbothlinesfornotcon