Tag: uiviewcontroller

如何通过代码从SKScene到UIViewController?

我想要的只是当用户触摸skscene中的skspritenode时,它会转到不同的视图,如performseguewithidentifier 。 谢谢你的帮助。 我可以发布代码,但它似乎是一个通用的问题,所以我觉得你不需要任何。 顺便说一下,我已经想出了如何检测敲击skspritenode。 我一直在看这个很长时间,我很难过。 请帮忙。

在通话状态栏(不能满足约束条件)

就像这个问题: 自动布局和通话状态栏和这个问题: 调整通话状态栏的大小? ,我有问题的通话状态栏搞砸了我的视图布局。 这是我的嵌套结构。 我有一个自定义模式ViewController嵌套在另一个ViewController。 每当“通话状态栏”显示(然后closures)时,就会发生以下情况: 这是一个在通话状态栏显示之前的样子: 发生错误后状态栏的背景蓝色是根视图控制器的背景颜色。 每当显示“通话状态栏”时,都会打印出以下错误信息: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted […]

如何在解除模态视图控制器时保持呈现视图控制器的方向?

我有这个应用程序,我正在工作,我需要所有我的视图控制器,但一个是在肖像。 单一的视图控制器是特殊的我需要它能够旋转到任何方向的电话是在。 要做到这一点,我模式(没有embedded在NavigationController中) 所以(例如)我的结构是这样的: 窗口 – 肖像 根视图控制器(UINavigationController – Portrait) 主视图控制器(UIViewController – Portrait) 详细信息视图控制器(UIViewController – 肖像) 。 。 。 模式视图控制器(UIVIewController – 全部) 现在,当我closures我的模式视图控制器在横向位置我的父视图控制器也被旋转,即使它不支持该方向。 应用程序中的所有UIViewControllers和UINavigaionControllers都从实现这些方法的相同的一般类inheritance: override func supportedInterfaceOrientations() -> Int { return Int(UIInterfaceOrientationMask.Portrait.toRaw()) } 我的模式视图控制器再次覆盖这个方法,它看起来像这样: override func supportedInterfaceOrientations() -> Int { return Int(UIInterfaceOrientationMask.All.toRaw()) } 更新1 它看起来像只发生在iOS8 Beta上。 有人知道是否有什么改变视图控制器的旋转或这只是一个testing版中的错误?

以编程方式更改storyBoard的rootViewController

我用Storyboards创build了我的项目。 根ViewController位于Storyboard ,我没有在appDelegate编写单个代码。 现在,我想显示我的应用程序的一个浏览,所以我想要从根目录Tab Bar更改根视图控制器到我的TourVC,当应用程序的巡视完成后,我想再次切换回我的根视图控制器到Tab Bar 。 所以我在网上查了一下,跟着以下几点 1)从app.plist文件中删除Storyboards ,2)取消选中Storyboards选项“isInitialViewController”,在Tab Bar控制器的情况下检查,因为它的根ViewController ,3)将此代码添加到appDelegate.m文件中。 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; ProductTourViewController *PT = [[ProductTourViewController alloc] initWithNibName:@"ProductTourViewController" bundle:nil]; self.window.rootViewController = PT; [self.window makeKeyAndVisible]; return YES; 但我的应用程序崩溃与此错误日志, [ProductTourViewController selectedViewController]: unrecognized selector sent to instance 0x1766a9e0 我还得到一个警告, Unsupported Configuration: Scene is unreachable due to lack of entry points and […]

Segue导致应用程序冻结(没有崩溃或错误抛出)

我已经在这个应用程序上工作了好几个月了,从我记忆中来说,我从来没有遇到过一个问题。 代码在调用performSegueWithIdentifier方面是不变的,但自从我最近更新到Xcode 7和iOS 9之后,我一直无法解决这个问题。 我努力了: 删除button和创build新的buttonw / segue链接 使用从button直接segue查看,而不使用performSegueWithIdentifier 将button连接到新的空白viewController 当我按下button时,目标VC上不会调用初始加载函数(例如: ViewDidLoad , ViewWillAppear等)。 当我将它连接到一个空白的视图,segue工作正常,在相同的代码。 由于代码永远不会停止或中断,而只是似乎“冻结”,而仍然在Xcode上运行,我似乎甚至不能缩小到这个问题导致的问题。 我有一个类似的segue,也从同一个ViewController的其他button调用,没有任何问题。 对此事的任何想法都非常感激! 编辑:我已经缩小到UITextView导致问题的问题。 一旦文本视图被删除的页面加载罚款通过segue。 我不知道iOS 8和iOS 9之间在UITextView方面有什么变化,因为我将不得不删除文本视图,并完全重新添加新的文本视图。

我如何从SKScene展示一个UIViewController?

我正在通过Sprite Kit进入iOS,我认识到这是不明智的。 我的目标是在游戏结束后显示“分享”button。 点击分享button应呈现一个SLComposeViewController(Twitter的份额)。 现场的内容不应该改变。 指示“Game Over”的游戏逻辑位于SKScene的子类SpriteMyScene.m中。 我可以在游戏上显示Sharebutton -(void)update:(CFTimeInterval)currentTime { if (gameOver){ UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(sendToController) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; } } – (void)sendToController { NSLog(@"ok"); SpriteViewController *viewController = [SpriteViewController alloc]; [viewController openTweetSheet]; } 我卡住的地方是试图让showTweetButton方法工作。 我的SpriteViewController.m看起来像这样: – (void)openTweetSheet { SLComposeViewController *tweetSheet = […]

如何实现使用多个ViewController的UIPageViewController

我一直在一个简单的testing应用程序来学习UIPageViewController的来龙去脉。 我有它的工作,但我不相信我的执行是最好的方法。 我希望你们中的一些人能把我指向正确的方向。 为了获得基本的理解,我以本教程为出发点。 http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ 本教程将创build一个应用程序,该应用程序为viewController提供的每个页面使用一个UIPageViewController 。 不过,我需要利用UIPageViewController来滚动具有完全不同布局的页面。 因此,为了让本教程更进一步,我创build了一个在详细视图中使用UIPageViewController来显示三个不同视图控制器的主 – 细节应用程序。 我坚持只显示这个testing应用程序的图像和标签,但我目前正在build设的应用程序有三个viewController将包含tableview,imageView和textViews,或一些textFields。 这是我的testing应用程序的故事板。 我使用DetailViewController作为PageViewController的数据源。 在DVC的viewDidLoad中,我以这种方式build立将在三个内容视图控制器firstViewController , secondViewController和thirdViewController中使用的标签和图像。 if ([[self.detailItem description] isEqualToString:@"F14's"]) { //Here the page titles and images arrays are created _pageTitles = @[@"Grim Reapers", @"Breakin the Barrier!", @"Top Gun"]; _pageImages = @[@"F14_Grim.jpg", @"F14boom.jpg", @"F14_topgun.jpg"]; //Here I call a method to instantiate the viewControllers FirstController […]

在iOS中出现键盘时向上移动UIView

我有一个UIView,它不在UIScrollView里面。 我想在键盘出现时向上移动视图。 在我尝试使用这个解决scheme之前: 当键盘出现时,如何使UITextField向上移动? 。 这工作正常。 但是,在将数据插入到文本框之后,它将我带到另一个视图,当我回到此页面时,它只是跳跃,而我看不到我的文本字段。 有没有更好的解决scheme,对于这个问题? 提前致谢!

在Swift中改变VC问题。 如何在标签栏控制器中的视图之间传递数据?

我有四个ViewController,我不使用UITabbedbar,因为这是更难以定制。 我使用模态赛格,但我认为内存消耗是过度的。 这是我的第一个和第二个VC的屏幕截图。 我必须使用正确的更改视图? 这是我使用的代码: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { if (segue.identifier == "second") { let secondVC = segue.destinationViewController as SecondViewController; } }

如何在Swift中从另一个ViewController的TableView中重新加载数据

在一个ViewController中,我试图在另一个ViewController的TableView中重新加载数据,如下所示: (self.presentedViewController as! tableViewController).table.reloadData() where tableViewController是TableView的控制器中的类(这不是上层驼,我知道),table是TableView。 那么,这样做会产生“致命的错误:意外地发现零,而解包可选值”,我想这是有道理的,因为“presentViewController”尚未加载。 我也试过这个: (self.navigationController!.viewControllers[self.navigationController!.viewControllers.count – 2] as! tableViewController).table.reloadData() 这产生了相同的结果(我确保tableViewController在navigationController栈的当前ViewController下)。 我很困惑我应该做什么…我觉得应该更容易引用不同视图控制器中的属性。 我可能有点模糊; 如果我是,告诉我你需要知道什么!