uiviewcontroller

How do I notify system when supportedInterfaceOrientations changes?

一曲冷凌霜 提交于 2019-12-21 07:08:59
问题 My root view controller's implementation of supportedInterfaceOrientations almost always returns UIInterfaceOrientationMaskAll , however there is one edge case where it returns UIInterfaceOrientationMaskLandscape . This is working, if the user rotates the device. However if the device is being held in portrait mode the supportedInterfaceOrientations method does not ever get called, unless the user manually rotates the device. How can I programatically tell the system that the return value of

when iphone Device orientation is face up/down, can I tell if it´s landscape or portrait?

半城伤御伤魂 提交于 2019-12-21 06:58:31
问题 I got this code that if the device is in landscape left/right or upside down it rotates and shows another view controller. but if it´s in the orientation face up or face down, then how can I tell if it´s in landscape mode or portrait? cause I only want to rotate if it´s face up or down and in landscape mode - (void)viewDidAppear:(BOOL)animated { UIDeviceOrientation orientation = [[UIDevice currentDevice]orientation]; NSLog(@"orientation %d", orientation); if ((orientation == 2) ||

iPhone - Change target or selector for Back Button on UINavigationController

烈酒焚心 提交于 2019-12-21 06:18:36
问题 The default behaviour when pushing a UIViewController on a UINavigationController is for the OS to display a back button that pops the UIViewController off again. I have the desire to set a different behavior for this back button (to go back two screens) - is there anyway I can do this without having to create my own back button with custom graphic etc. Thanks :) 回答1: As I half suspected originally, this isn't possible any exceptionally easy way. So same method applies when creating any

Pushing View Controller Twice

 ̄綄美尐妖づ 提交于 2019-12-21 06:07:40
问题 Within my app I'm having an issue with the following error: Pushing the same view controller instance more than once is not supported It's a bug report that's comeback from a few users. We've tried to replicate it but can't (double tapping buttons etc). This is the line we use to open the view controller: let storyboard = UIStoryboard(name: "Main", bundle: nil) let editView = storyboard.instantiateViewControllerWithIdentifier("EditViewController") as! EditViewController editView.passedImage =

Navigate to ViewController from UIAlertController button click

时光毁灭记忆、已成空白 提交于 2019-12-21 05:57:34
问题 I am quite new to Swift development and I tried referring to the Swift UIAlertController API but couldn't figure out how to navigate to another UIViewController after clicking a button on the UIAlertController. I would appreciate any pointers, help or a solution to this problem. My code snippet is given below - @IBAction func showAlert() { let alertController = UIAlertController(title: "Disclaimer", message: "Disclaimer Text Here", preferredStyle: .Alert) let declineAction = UIAlertAction

Navigate to ViewController from UIAlertController button click

微笑、不失礼 提交于 2019-12-21 05:57:09
问题 I am quite new to Swift development and I tried referring to the Swift UIAlertController API but couldn't figure out how to navigate to another UIViewController after clicking a button on the UIAlertController. I would appreciate any pointers, help or a solution to this problem. My code snippet is given below - @IBAction func showAlert() { let alertController = UIAlertController(title: "Disclaimer", message: "Disclaimer Text Here", preferredStyle: .Alert) let declineAction = UIAlertAction

Touch events not working on UIViews inside UIScrollView

Deadly 提交于 2019-12-21 05:44:08
问题 I have a series of UIViews inside a UIScrollView, and the UIViewControllers for those views are not receiving the touch events. If I take the views out of the scroll view then it works. I have enabled userInteraction on the views but it's still not working! This must be possible and I'd be really grateful if someone could point me in the right direction! Thanks, Mike 回答1: Do the views have their own touch handlers, or are you relying on the viewcontroller to get the touches? Depending on how

How to get from SKScene to UIViewController?

自古美人都是妖i 提交于 2019-12-21 05:39:14
问题 I am new to programming and I am trying to build a simple game using Swift and SpriteKit. It looks good now but I have a little problem to solve. How do I get from a SKScene (Game) to a UIViewController in the Storyboard? My game looks like this. In the Storyboard i have 3 views (Main menu, About and Game Over) and 1 SKScene (Game). When the player clicks on the play button in the main menu he gets to the game SKScene. When the player fails I want to get to a new UIViewController where I can

Pass data between ViewController and TabBarController

独自空忆成欢 提交于 2019-12-21 04:51:33
问题 I have couple of questions. How to pass the data (which i got after the Alamofire request is finished), to one of children of TabBarController? The first problem i have is that i can't override the func prepareForSegue inside login action(when the button is tapped), it says i can override only class members. But if i put the func outside of IBAction then i won't send the data that i need. And the second problem is, when i put the overrided function outside of IBAction, and the code look like

Swift/iOS: IBOutlet nil after loading view controller

谁都会走 提交于 2019-12-21 04:27:31
问题 I'm building an app (in XCode 8.2.1) where some objects are displayed on a 2D board, and when the user taps one of these objects some info should be displayed about it as a styled modal info box. My design is to have the info written in a separate view controller, which I would display when needed. I've designed a basic stub for the second view controller and added a single label to it in the interface builder. Then I've ctrl-linked this label to my custom VC class: class InfoViewController: