草庐IT

poo1ViewController

全部标签

ios - 快速以编程方式打开 viewController

我想通过代码在按钮上打开新的UIViewController。我已经在Storyboard中制作了Controller,只想链接它,而且我不想使用XIB接口(interface)或nibName? 最佳答案 要打开新的ViewController,你需要在按钮点击事件中写下这一行:self.performSegueWithIdentifier("GoToViewController",sender:self)要链接新的ViewController,请按照以下步骤操作:从Storyboard中选择新建ViewController并右键

ios - 如何在半屏上呈现 ViewController

我有一个UIViewController,它只有一个UIView,它从底部覆盖了1/3的viewController。像这样我想在另一个ViewController上显示这个viewController。它应该从底部动画出现,并且应该消失到底部动画。但我不希望它覆盖整个屏幕。显示它的viewController应该在后面可见。这似乎是一个基本问题,但我无法完成它。有人可以给我指个方向吗?编辑:这是我迄今为止尝试过的。我创建了这些类//MARK:-classMyFadeInFadeOutTransitioning:NSObject,UIViewControllerTransitionin

ios - 在 ViewController 之外显示 UIAlertController

我无法显示我的UIAlertController,因为我试图在一个不是ViewController的类中显示它。我已经尝试添加它了:varalertController=UIAlertController(title:"Title",message:"Message",preferredStyle:.Alert)UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController,animated:true,completion:nil)哪个不工作..

ios - `_statusBarTintColorLockingControllers` 处的属性 `UIApplication` 将 ViewController 保留在内存中

使用Xcode8新内存调试器,我发现内存中有一个不应该存在的ViewController,指向它的强引用来自UIApplication中这个神秘的_statusBarTintColorLockingControllers数组。有人知道它来自哪里吗?更重要的是,如何让我的VC摆脱困境? 最佳答案 _statusBarTintColorLockingControllers似乎不是这里的真正问题。我有相同的内存图,直到我解决了一个保留周期,我在委托(delegate)属性上忘记了weak。 关

ios - 如何在 Swift 中使用 "Show my current location on google maps, when I open the ViewController?"?

我正在使用iOS(Swift)的Googlemapsdk。有谁知道如何“在我打开ViewController时在谷歌地图上显示我的当前位置”?实际上它就像谷歌地图应用程序。当您打开Googlemap时,蓝点将显示您当前的位置。您不需要在第一次按“myLocationButton”。所以这是代码:importUIKitimportCoreLocationimportGoogleMapsclassGoogleMapsViewer:UIViewController{@IBOutletweakvarmapView:GMSMapView!letlocationManager=CLLocation

ios - Swift - 从 viewController 访问 AppDelegate 窗口

我在我的应用程序中进行了演练(入职流程),我想要一个跳过按钮。该按钮位于viewController上,因此我发现移动到另一个viewController的最佳方法是访问应用程序委托(delegate)窗口。但是,它总是给我一个错误,AppDelegate.Type没有名为“window”的成员。@IBActionfuncskipWalkthrough(sender:AnyObject){letappDelegate=UIApplication.sharedApplication().delegateas!AppDelegateAppDelegate.window!.rootViewC

ios - 在 Swift 中从另一个 ViewController 访问变量

我有以下ViewController:classPageContentViewController:UIViewController{varpageIndex:Int}如何从另一个ViewController访问pageIndex?我需要在这个函数中访问pageIndex:funcpageViewController(pageViewController:UIPageViewController!,viewControllerBeforeViewControllerviewController:UIViewController!)->UIViewController!{//varind

swift - 在 Swift 中对我自己的 ViewController 进行单元测试时使用未声明的类型 'ViewController'?

我一直在尝试用Swift编写测试用例来测试我的ViewController。但是,当我尝试在XCTestCase中实例化我自己的ViewController时,我得到了“使用未声明的类型‘ViewController’”。(ViewController是我自己的UIViewController类的名字)有没有人遇到过这个问题?我正在使用Xcode6beta5 最佳答案 swift1如果您不使用框架,您也应该将ViewController.swift文件的目标成员添加为您的测试目标。选择类文件添加到目标,如图所示:或如果您是ViewC

ios - Swift:ViewController 中的 TableView

我在MainstoryBoard中有一个ViewController。我添加了TableView主Storyboard:此外,我在ViewController类之外有一个数组,我希望数组中的对象显示在TableView中。我不知道该怎么做。我在TableView和ViewController之间连接了委托(delegate)。 最佳答案 您在类声明下方添加一个新的TableView实例变量。@IBOutletweakvartableView:UITableView!要符合UITableViewDelegate和UITableView

ios - 从 xib 文件加载 ViewController

我有一个MyViewController.swift和一个MyViewController.xib来呈现MyViewController的布局。我尝试了不同的方法来加载这个ViewController,包括://1letmyVC=UINib(nibName:"MyViewController",bundle:nil).instantiateWithOwner(nil,options:nil)[0]as?MyViewController//2letmyVC=NSBundle.mainBundle().loadNibNamed("MyViewController",owner:self,o