草庐IT

uiviewcontrollers

全部标签

ios - 如何通过代码从 SKScene 转到 UIViewController?

如果当用户触摸skscene中的skspritenode时,它​​会转到不同的View,如performseguewithidentifier。谢谢你的帮助。我可以发布代码,但这似乎是一个通用问题,所以我认为您不需要任何代码。顺便说一句,我已经想出了如何检测skspritenode的敲击。我已经看了很长时间了,我很难过。请帮忙。 最佳答案 您不能从SKScene中呈现viewController,因为它实际上只在SKView上呈现。您需要一种方法来向SKView的viewController发送消息,后者将呈现viewControl

iphone - 什么时候为自定义 subview 子类化 UIViewController?

我已经看到自定义subview作为UIViewController子类实现,但也许可以作为UIView子类实现。我什么时候应该为subview继承UIViewController而不是UIView?子类化UIViewController有什么缺点吗? 最佳答案 就个人而言,当我需要一些重要的逻辑继续时,我会使用UIViewController子类来完成。此外,如果我正在寻找您从UIViewController获得的一些行为,例如以模态方式或在导航Controller中呈现它。如果您正在做一些相当简单或轻量级的事情,UIView子类通

ios - UIViewController 的子类不捕获触摸事件

我有一个父类(A),它是UIViewController。比我创建的类B是类A的子类。发生的事情是我无法使用诸如touchesBegan之类的方法捕获类B中的触摸事件。但是如果我在类A中实现这个方法......它们会被调用。@interfaceA:UIViewController.....@interfaceB:A 最佳答案 要使用UIViewController,必须执行如下事件:-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{UITouch*touch;C

ios - 在最新的 xcode 5 中分别添加到 Storyboard 中的 UIViewController 后看不到 UIView

我在xcode5中将UIView拖放到Storyboard中的UIViewController,它已添加,但我在Storyboard中看不到该UIView。谁有解决办法?在以前版本的xcode中,我确实通过以下链接中描述的过程让它工作:-https://stackoverflow.com/a/14515818/952440但现在它在最新的xcode5中不起作用。为了您的信息,我在下面的Storyboard中添加了屏幕截图:- 最佳答案 您必须将这些View添加为主视图的subview。只需将它们拖到顶部View即可。如果您不想默认显

iphone - UIViewController - UIModalPresentationCurrentContext 不旋转 presentingViewController

我曾经使用呈现样式UIModalPresentationCurrentContext从另一个UIViewController呈现一个UIViewController。但它不允许我旋转presentingviewcontroller(呈现新UIViewController的UIViewController)self.modalPresentationStyle=UIModalPresentationCurrentContext;NewViewController*newViewController=[[NewViewControlleralloc]initWithNibName:@"Ne

ios - 如何将使用 UIImagePickerController 拍摄的照片设置为在自定义 UIViewController 中查看/修改?

我目前使用的是默认的UIImagePickerController,拍照后会立即显示以下默认屏幕:我的问题是,我如何才能使用自己的自定义UIViewController来查看结果图像(从而绕过此确认屏幕)。请注意,我不对使用自定义相机控件或照片库中的图像的UIImagePicker自定义覆盖感兴趣,而只是跳过此屏幕并假设照片taken是用户会喜欢的。谢谢! 最佳答案 尝试使用此代码来保持生成的图像大小相同:首先为UIImageview创建IBOutlet。-(void)imagePickerController:(UIImagePi

ios - 在 iOS 中,每个 UIView 都应该有一个 UIViewController 吗?

许多View都有subview,这些subview不一定需要关联自己的Controller。在苹果的owntutorial在创建自定义View时,他们实际上并没有为每个subview创建一个子UIViewController。但是,我经常遇到这样的情况:我有一个View层次结构,其中subview的某些subview有一个发送网络请求的按钮。在那种情况下,我可以做一个目标:myView.addTarget(self,action:"networkRequest:",forControlEvents:UIControlEvents.TouchDown)然后在同一个myView类中我可以处

iphone - iOS - 核心数据 - 一个 UIViewController 中的多个 NSFetchedResultsController

我正在尝试构建一个使用CoreData的iPad应用程序。但我面临着设计和编码问题。假设我将一个UIViewController添加到我的窗口并在该ViewController内,我需要显示两个TableView(2个不同的实体)和2个View(另外2个实体)(因此我需要为一个UIViewController获取4个实体)。我只找到了解释如何将NSFetchedResultsController与一个UITableView一起使用的教程!我的问题是:我应该在我的viewController中声明2个UITableView和2个NSFetchedResultsController吗?或者

ios - 在状态恢复期间创建和恢复 UIViewControllers 的正确方法?

我想在我的不使用Storyboard的应用程序中进行状态恢复。我看到我的主要应用程序ViewController在状态恢复期间实例化了两次-你如何确保它只创建一次?我理解流程的方式,application:willFinishLaunchingWithOptions和pplication:didFinishLaunchingWithOptions将使用commonInit方法来设置应用程序UIWindow及其rootViewController。在我的例子中,rootViewController是一个UINavigationController,它有一个名为“MyMainViewCon

ios - 如何像 actionSheet 一样呈现 UIViewController?

我想呈现一个只占据屏幕下半部分的View,背景View保持可见,没有可能的交互。就像一个带有actionSheet风格的UIAlertContoller。如何在Swift中做到这一点? 最佳答案 将该View创建为普通的UIViewController,为其分配一个标识符,然后像这样实例化它:(尽管将其保留为成员变量,您将需要它)varcontroller=self.storyboard!.instantiateViewControllerWithIdentifier("yourIdentifier")as!UIViewContro