草庐IT

ViewController3

全部标签

ios - UITesting、XCTest 当前 ViewController 类

简单的问题。我得到了执行segue到下一个ViewController的按钮。我想编写UIXCTest来告诉我它是否打开了我想要的ViewController。 最佳答案 UI测试框架无法访问您的应用程序代码,这使得无法对实例进行类断言。您无法直接告诉屏幕上的Controller类。但是,如果您以稍微不同的方式考虑您的测试,您可以做出非常相似的断言。编写您的测试,就好像您是用户一样。您的用户不关心他/她正在查看ItemDetailViewController还是ItemListTableViewController,所以你的测试也不

swift - 在 ViewController 和 ContainerViewController 之间传递数据

我正在开发一个应用程序,需要在View和containerView之间传递数据。我需要从两个View发送和接收数据。让我更好地解释一下:我可以通过协议(protocol)更改LabelMaster(触摸容器按钮),但我不能更改标签容器(触摸主按钮)。发生的事情是Master通过以下方式与容器连接。但是没有一个followContainer链接到Master。我尝试添加butsegue到,但它成功了。主视图Controller:importUIKitprotocolMasterToContainer{funcchangeLabel(text:String)}classMaster:UIV

swift - 在 ViewController 和 ContainerViewController 之间传递数据

我正在开发一个应用程序,需要在View和containerView之间传递数据。我需要从两个View发送和接收数据。让我更好地解释一下:我可以通过协议(protocol)更改LabelMaster(触摸容器按钮),但我不能更改标签容器(触摸主按钮)。发生的事情是Master通过以下方式与容器连接。但是没有一个followContainer链接到Master。我尝试添加butsegue到,但它成功了。主视图Controller:importUIKitprotocolMasterToContainer{funcchangeLabel(text:String)}classMaster:UIV

ios - 文件 viewController.swift 是模块 "coreData"的一部分,忽略导入

我尝试导入CoreData,但出现警告“文件viewController.swift是模块“coreData”的一部分,忽略导入”AScreenShotimportUIKitimportCoreDataclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.}overridefuncdidReceiveMemoryWarning(){super.didRecei

ios - 文件 viewController.swift 是模块 "coreData"的一部分,忽略导入

我尝试导入CoreData,但出现警告“文件viewController.swift是模块“coreData”的一部分,忽略导入”AScreenShotimportUIKitimportCoreDataclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.}overridefuncdidReceiveMemoryWarning(){super.didRecei

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()如何在单元格被选中时获取单元格的标签,然后将其传