草庐IT

UiviewController

全部标签

ios - 相同的 View Controller 显示不同

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

ios - Swift:为什么我仍然需要可选值?

我已经阅读了几篇有关它的文章并理解了基本原理,并且同意它在某些情况下可能很有用。但是,大多数时候,如果我在不该出现的地方出现nil,我希望我的程序崩溃——这就是我如何知道出现问题的原因!此外,我读到使用可选值可以缩短代码。这怎么可能?据我所见,它们背后的整个想法是它们可以有一个值或nil所以你必须做额外的检查,而以前这是没有必要的!一直需要使用“as”是怎么回事?它只会让一切变得更加冗长和冗长。例如,在Objective-C和Swift中比较以下代码Objective-C:UIViewController*vc=[self.storyboardinstantiateViewContro

ios - 具有两个自动布局标签的 TableView 单元格,在 UIViewController 中不显示所有行

我有一个带有两个UILabel的UITableViewCell,使用Storyboard和Autolayout。问题是第二个标签只显示两行文本,即使要显示更多行也是如此。编辑:当Controller是UIViewController而不是TableViewController时会出现问题,它在TableViewController中按预期工作我已将numberoflines属性设置为0在自动布局中,我从所有四个侧面固定了两个标签。但这并没有帮助,只显示了一行。当我将heightForRowAtIndexPath与systemLayoutSizeFittingSize一起使用时为了获得行

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")最后

ios - swift 如何传递 UIViewController<XXXDelegate> 类型的参数

我有这个功能来呈现登录/注册模态视图Controller。传递的参数必须是UIViewController(UIViewController代表方法,AuthViewControllerDelegate代表方法)staticfunccheckAuthError(controller:UIViewController,err:NSError){iferr.code==401{letauthViewController=viewControllerWithIdentifier("AuthViewController")as!AuthViewControllerauthViewControl

Swift:以编程方式枚举来自 UIVIewController 的传出 segues

我想列出来自UIViewController的输出转场,如ProgrammaticallyenumerateoutgoingSeguesforaUIViewController中所述,但在Swift中。(swift2、Xcode7、iOS8+)。我可以overridefuncviewDidLoad(){super.viewDidLoad()lets=valueForKey("storyboardSegueTemplates")print("switchingVC:segues:\(s)")}并且产生类似的输出switchingVC:segues:Optional(("","",""))

ios - NSNotification:尝试在其 View 不在窗口层次结构中的 ViewController 上显示 UIAlertController

我正在尝试在通过NSNotification调用的函数中的ViewController中显示UIAlertController。但是我收到错误:Attempttopresentonwhoseviewisnotinthewindowhierarchy!NSNotification是从我UI中的其他内容的完成block(我猜是回调)发布的。因为它是一个回调,所以无法显示。因此我想我会尝试NSNotificationCentre来解决这个问题而不使用rootViewController来显示警报。我的代码是:overridefuncviewDidAppear(animated:Bool){/

ios - 如何将数据从 View Controller 传递到导航 Controller ,然后再传递到另一个 View Controller ?

我有来自ViewController的数据,我想传递另一个ViewController,但我已将其设置为模态显示,因此我在它们之间有一个导航Controller。如何将数据从第一个ViewController通过导航Controller传递到第二个ViewController?我在第一个ViewController中有这段代码:overridefuncprepare(forsegue:UIStoryboardSegue,sender:Any?){ifsegue.identifier=="presentPopup"{letdestViewController=segue.destinat

ios - 如何同时呈现两个 View Controller ?

我的目标是呈现一个ViewController而不直接关闭它的presentingViewController.为了更清楚,请考虑以下示例:引用这个Storyboard:假设第一个黑色ViewController是第一个(初始)ViewController,它应该呈现第三个白色ViewController;问题是白色ViewController应该关闭到第二个橙色ViewController,但不是黑色ViewController,所以它应该表现得像:黑色VC礼物白色VC。WhiteVC解雇给OrangeVC。OrangeVCDismisses给BlackVC。如何应用这样的行为?备注

swift - 使用 UIViewController 不隐藏选项卡栏

我使用选项卡栏将UIViewController添加为PresentViewController,然后View如下所示:选择任何选项后,我需要隐藏标签栏,但我的屏幕看起来像:请给我建议解决方案。我正在添加一个ViewController:self.presentViewController(responseSelector,animated:true,completion:nil) 最佳答案 我找到了解决方案。letresponseSelector=ResponseSelectorViewController(responseId: