草庐IT

MX_Controller

全部标签

swift - 使用 NSNotifications 在 View Controller 之间传递变量

我正在尝试使用NSNotifications在两个ViewController之间传递一个整数变量,但是尽管现在已经弄清楚如何检测另一个ViewController发送的通知,但我仍然没有弄清楚如何在其中实际传递一个变量通知。这是我在发送变量的ViewController中的代码:funcpickerView(pickerView:UIPickerView!,didSelectRowrow:Int,inComponent:Int){varcolourSelected=rowprintln(colourSelected)NSNotificationCenter.defaultCenter

springboot的MockMvc单元测试(测试controller层方法)

所谓单元测试,即用一小段可以独立运行的代码,去测试一个比较底层的单独的功能。如果需要对controller层的方法进行测试,那么我们可以使用springboot提供的MockMvc,模拟客户端的请求来测试。 一、引入依赖   只有我们去执行测试类时,该依赖才会被加载  org.springframework.boot spring-boot-starter-test test二、理论知识详解1.@RunWith该注解为类级别批注,该注解的作用是告诉java这个类是以什么运行环境来运行2.@SpringBootTest 启动spring容器,用来指定springboot应用程序的入口类,该注解会

ios - 如何为 View Controller 的 View 设置多个位置状态?

我要解决的问题是:我有一个DetailViewController显示我的模型的数据,其中包含UIImageView、UITextFields等如果用户点击一个按钮,那些DetailViewController的View将移动到不同的位置并开始可编辑。可编辑时,如果用户点击其中一个UITextField(只有其中一个是特殊的),UITextField将移动到屏幕顶部,并且UITableView似乎会自动完成它(就像您在google上键入内容时一样)。用户也可以点击相同的按钮返回到显示状态(其中没有任何内容是可编辑的)。所以基本上我在ViewController中有一些View,有3种可

objective-c - 如何引用子类的父 View Controller ?

在这里你可以看到我已经将我的子类textView的委托(delegate)设置为它自己:importFoundationclassImageCaptionTextView:UITextView,UITextViewDelegate{overridefuncawakeFromNib(){super.awakeFromNib()delegate=self}现在在我的Controller中,我的委托(delegate)方法不起作用。我正在使用ImageCaptionTextView子类中的所有ImageCaptionTextView委托(delegate)方法,而不是它们以前所在的位置,即C

swift - 如何为 iOS 7 和 iOS 8 实现搜索 Controller

我的目标是我的应用程序应该在iOS7和iOS8上运行。由于UISearchDisplayController在iOS8中被弃用,我使用了iOS8的UISearchController。但它在iOS7中不起作用。如果我使用UISearchDisplayController那么它将起作用在iOS7中。但是为两个平台实现搜索Controller的最佳方法是什么?在iOS8中,我实现了如下搜索Controller-overridefuncviewDidLoad(){super.viewDidLoad()//SearchControllerSetupsearchController=UISear

ios - 相同的 View Controller 显示不同

我有两个subviewController,据我所知它们是相同的,但是其中一个出现了意外行为。这两个subviewController称为MenuLoggedInViewController和MenuLoggedOutViewController。他们的容器ViewController具有以下代码:overridefuncviewDidLoad(){super.viewDidLoad()//icommentoutoneofthesetwolinestoproducethedifferentresults:self.masterView=MenuLoggedOutViewControll

ios - 如何为 View Controller 的背景设置动画以在多种颜色之间淡入淡出?

如何在不导致无限内存问题的情况下做到这一点?我正在尝试这样的事情:overridefuncviewDidAppear(animated:Bool){view.backgroundColor=UIColor.whiteColor()fadeBackground()}letcolors=[UIColor.blueColor(),UIColor.redColor(),UIColor.greenColor(),UIColor.orangeColor(),UIColor.purpleColor()]funcfadeBackground(){UIView.animateWithDuration(4

ios - Swift xCode 6.4 - 在第二个 View Controller 中使用由 TableView Controller 生成的变量

我整天都在用谷歌搜索一个可能很简单的问题,但我没答对。希望有人能帮助我。我有一个tableviewController,其中一个原型(prototype)单元格包含三个自定义标签。当我运行该应用程序时,TableViewController将生成大约150个TableView单元格,其中的内容从一个csv文件中解析。当我点击这些单元格之一时,用户将被转发到第二个ViewController,显示他的单元格选择的一些额外信息文本。在用户单击tabelview单元格的同时,一个变量将更新为相应的tableview-row-number(例如,最后一个tableview单元格为150。现在我

ios - 在 Collection View 的容器 View 中呈现 View Controller didSelectItemAtIndexPath swift

当我从CollectionView中选择一个单元格时,我试图在容器View中呈现一个ViewController。问题是我似乎无法理解如何在CollectionView下方的容器中呈现它。我试过:if(indexPath.row==0){//PresentingfirstviewcontrollerletdetailedViewController:ViewController=self.storyboard!.instantiateViewControllerWithIdentifier("ViewController")as!ViewControllerself.presentVi

ios - 如何使用 swift 以编程方式转换到不同 Storyboard 中存在的不同 View Controller ?

letcustomerStoryboard=UIStoryboard(name:"Customer",bundle:nil)//First(Current)storyboardletagentStoryboard=UIStoryboard(name:"Agent",bundle:nil)//SecondstoryboardvarotherVC=UIViewController!//ViewControllerreferenceotherVC=agentStoryboard.instantiateViewControllerWithIdentifier("AgentProfile")最后