草庐IT

AnuncioV2ViewController

全部标签

ios - 具有不同单元格数量的 viewController 中的多个 Collection View

好像有个类似的问题here但这并没有解决我的问题。我在我的viewController中创建了两个collectionView,如下所示:lety=self.view.frame.heighttitleView=UIView(frame:CGRect(x:0,y:50,width:self.view.frame.width,height:y-100))letmiddle=CGPoint(x:10,y:titleView.bounds.height/10)letframe=CGRect(origin:middle,size:CGSize(width:self.view.frame.wid

swift - 如何将 ViewController 添加到 UITabBarController 并以编程方式加载它?

我正在尝试将自定义viewController放入UITabBarController,然后呈现它。但是当我尝试下面的内容时,我得到的是一个空白屏幕,底部有一个空白标签栏。@IBActionfuncdidOpenTabs(_sender:Any){lettabBarController=UITabBarController()letvc=ViewController()letcontrollers=[vc]tabBarController.viewControllers=controllersself.present(tabBarController,animated:true,com

ios - 如何将 UIBarButtonItem 放在 Swift4 上的 NavigationController 的 ViewController 上?

我有一个用于导航的三个屏幕。但是在其中一个中,我不能放置UIBarButtoItem。此屏幕用于创建寄存器,我想创建一个“保存”按钮,就这么简单。当我这样做时,我选择了BarButtonItem,XCode不会让我掉落在栏上。并且以编程方式,也不起作用。我试过这个:(没有发生)varbtSalvar:UIBarButtonItem?overridefuncviewDidLoad(){super.viewDidLoad()btSalvar=UIBarButtonItem(title:"Salver",style:.plain,target:self,action:nil)self.nav

ios - 如何在 ios,swift 中初始化我的 ViewController 扩展中的 ui 元素

我有一个ViewController,它有一个以编程方式创建的标签,如下所示。classMyController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()view.backgroundColor=.whitesetupUI()}funcsetupUI(){//addedansetuptheviewconstraints.}}Thisworksproperly.ThenItriedtomovealltheUIelementoftheviewcontrollertoit'sextensionbycreati

ios - 我有一个包含不同/多个 UIView 的 Storyboard ,我希望每个 UIView 都有一个 ViewController。 swift

我有一个具有不同View的Storyboard,我不想要ViewController.swift中的所有代码,我宁愿为每个UIView提供一个Swift。可能吗?我该怎么做? 最佳答案 使用UIContainerView而不仅仅是UIView。当您将UIContainerView拖到Storyboard中时,它会自动创建一个View。只需在您的项目中创建一个新的CocoaTouchClass文件。确保文件放在UIViewController下然后单击自动生成的新View,转到“属性”,然后选择新的Swift文件。这会将View连接到

macos - 将 managedObjectContext 获取到初始 viewController OS X 的方法

这就是我目前的做法,但我想知道Apple是否建议这样做。我读过一些关于这个的辩论。letappDelegate:AppDelegate=NSApplication.sharedApplication().delegateasAppDelegateifletmoc=appDelegate.managedObjectContext{//dostuffhere}所以这只是将它从AppDelegate获取到第一个viewController。从那里我猜测使用segues是传递managedObjectContext的方式?使用上面的代码非常烦人,因为我将其输入到viewController中需

ios - 如何将手势识别器添加到 ViewController 及其子项?

我正在制作类似于EuroSport的应用程序。我的rootviewController是pageViewController,它有3个VC。左右滑动可以更改VC。接下来,我添加了侧边栏菜单。我想将手势识别器添加到整个rootViewController。这就是我添加手势的方式:self.exitPanGesture=UIPanGestureRecognizer()self.exitPanGesture.addTarget(self,action:"handleOffstagePan:")self.sourceViewController.view.addGestureRecognize

ios - 快速 HTTP 请求。 ViewController.type 没有名为 "url"的成员

我一直在尝试使用在每个教程和堆栈溢出问题中找到的相同代码快速发出HTTP请求,但我一直遇到相同的错误;ViewController.type没有名为“url”的成员(url是我的字符串)。我的代码:leturl=NSURL(string:"http://www.stackoverflow.com")lettask=NSURLSession.sharedSession().dataTaskWithURL(url!){(data,response,error)inprintln(NSString(data:data,encoding:NSUTF8StringEncoding))}task.

ios - Swift:dismissViewController 并实例化另一个 ViewController

我试图关闭一个ViewController并同时显示另一个ViewController。当Level1Controller()完成并调用self.dismissViewController()时,我希望它将我带到另一个名为EndScene().这是让我最接近的代码。self.dismissViewControllerAnimated(true,completion:{()->Voidinletstoryboard=UIStoryboard(name:"Main",bundle:nil)letnextViewConroller=storyboard.instantiateViewCont

ios - 从 UIViewController 返回到第一个 ViewController

手头的问题如下:我展示了一个UIAlertController。如果用户按下删除键,View应该返回到第一页,属于classTableViewQuery:PFQueryTableViewController类。.importUIKitclassDetailViewController:UIViewController{varcurrentObject:PFObject?@IBActionfuncpressDelete(sender:AnyObject){letdeleteUser=UIAlertController(title:"Areyousure?",message:"Areyou