草庐IT

viewController

全部标签

ios - 如何在 Swift playground 中停止帧的大小变为 1024x768

UIViewController中主视图的frame变为1024x768一开始问题不明显,后来做布局的时候就麻烦了。如何确保框架与我使用.preferredContentSize设置的大小保持相同?importUIKitimportPlaygroundSupportclassMyViewController:UIViewController{overrideopenfuncviewDidLoad(){super.viewDidLoad()self.view.backgroundColor=UIColor.whiteself.view.frame//Whenrunplaygroundsh

ios - 两个 Storyboard,一个标签栏 Controller

因为我们是在一个团队中工作,所以我们确实需要在一个iOS应用程序项目中有多个Storyboard。我在某处读到,如果您使用的是选项卡栏Controller,则不能拥有多个Storyboard,但我相信我做到了。我的问题是:这是一个好的做法吗?您是否看到代码中有任何未保存的内容?您能预见future的任何错误吗?我有两个Storyboard,Main.Storyboard和Settings.storyboard。请注意,在MAIN中,我将入口点嵌入到新的TabBarController并通过InterfaceBuilder添加了两个View。和:以编程方式,我想添加第三个选项卡,它转到U

macos - 如何从我的 NSWindow 调用我的 ViewController 中的函数?

我正在使用Swift和Storyboard。我不知道如何从我的NSWindow访问我的ViewController。Storyboard似乎不允许我创建从一个到另一个的导出。我相信有一些简单的方法可以做到这一点。编辑:为什么这不可能? 最佳答案 从我的NSWindow我可以像这样访问NSViewController:letcontroller=self.windowController()?.contentViewControlleras!ViewController;ViewController是我的NSViewControlle

swift - EXC_BAD_INSTRUCTION(代码 = EXC_I386_INVOP,子代码 = 0x0)

我正在创建一个温度转换器。当我运行应用程序时;输入温度,选择转换方式并点击转换。出现错误。错误是:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)这是我的ViewController代码:importUIKitclassViewController:UIViewController,UIPickerViewDataSource,UIPickerViewDelegate{@IBOutletweakvarorginalValue:UITextField!@IBOutletweakvarconvertFrom:UIPickerView!letpic

ios - 从 swift viewcontroller 调用 .c 文件中的 swift 函数

我正在IOS中调用应用程序。该项目进展swift。我使用PJSIP作为第三方库来调用电话,并使用Asterisk作为Voip服务器。我已经设置了服务器,还在我的项目中集成了PJSIP。我能够注册到服务器,调用电话,接听电话。当我收到显示用户ID和其他信息的调用时,我想初始化一个新的ViewController。接收调用方法用C实现。/*Callbackcalledbythelibraryuponreceivingincomingcall*/staticvoidon_incoming_call(pjsua_acc_idacc_id,pjsua_call_idcall_id,pjsip_r

ios - 如何从 UITabBarItem 获取 ViewController

当用户点击一个项目时,我想获取与该选项卡关联的ViewController。TabBar委托(delegate)不再提供ViewController委托(delegate)。相反,它提供了一个didSelectItem委托(delegate)。overridefunctabBar(tabBar:UITabBar,didSelectItemitem:UITabBarItem){}如何从UITabBarItem获取ViewController? 最佳答案 如果您使用的是UITabBarController而不仅仅是UITabBar,请考

swift - ViewController segue 和登录

我是Swift(和一般编程)的新手。我在使用登录功能时在Xcode中遇到了一些困难。我想要的是,如果没有返回错误,用户应该登录,用户应该被发送到另一个Controller。我已经阅读了Apple和performSegueWithIdentifier的一些文档(当然还有这里提出的一些问题),但是当我将segue与push一起使用时它仍然不起作用或modal被赋予一个标识符。应用程序崩溃,或者即使凭据不正确,用户也会被发送到我的UITabBarController。这是我的LogInViewController.swift:@IBActionfuncloginAction(sender:A

ios - 将 CollectionView 连接到 ViewController,连接 dataSource-Swift-XCode 时出错

我可以连接委托(delegate),但是,在连接数据源时出现以下错误:2015-07-1316:45:17.529paintApp[4628:168318]-[UIViewcollectionView:numberOfItemsInSection:]:unrecognizedselectorsenttoinstance0x7f8a12651c602015-07-1316:45:17.539paintApp[4628:168318]*Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'-[UIV

ios - 为什么我的 segue 导致 "unrecognized selector sent to instance"NSInvalidArgumentException?

尝试使用segue从我的第一个ViewController移动到我的第二个ViewController(都使用相同的Storyboard)。我的第一个ViewController有两个按钮,一个表示“男性”,一个表示“女性”(我知道,不是每个人都与这两个中的一个相关联),我希望其中一个按钮在单击后移动到第二个ViewController。我将按钮拖/放到我的代码中以获得以下内容:@IBActionfuncfemaleButton(_sender:AnyObject){Globals.onboardingList.append("girl")print("it'sagirl!")perf

IOS 为什么单元测试一个类调用 ViewController

我写了一个如下的单元测试:classTest445Tests:XCTestCase{functestPerformanceExample(){XCTAssert(true)}}当测试运行时,调用ViewController.viewDidLoad!有人可以解释为什么会这样吗?classViewController:UIViewController{staticvars=falseoverridefuncviewDidLoad(){super.viewDidLoad()ViewController.s=true//putthedebuggerhere.}}如果您编写此代码并将调试器放在V