viewcontroller

Open Specific View when Opening App from Notification

微笑、不失礼 提交于 2019-11-27 17:32:24
I have just added push notifications to my app. I'm wanting to have so that when a user opens the app from a notification, it will open a specific view controller and not my rootViewController. Here is my AppDelegate: #import "KFBAppDelegate.h" #import "KFBViewController.h" #import "AboutUs.h" #import "ContactUs.h" #import "KYFB.h" #import "KFBNavControllerViewController.h" #import "KFBTabBarViewController.h" #import "RSFM.h" #import "LegislatorInfo.h" #import "Events.h" #import "ActionAlertsViewController.h" #import "UAirship.h" #import "UAPush.h" #import "UAAnalytics.h" @implementation

presenting ViewController with NavigationViewController swift

偶尔善良 提交于 2019-11-27 17:14:47
I have system "NavigationViewController -> MyViewController", and I programmatically want to present MyViewController inside a third view controller. The problem is that I don't have navigation bar in MyViewController after presenting it. Can you help me? var VC1 = self.storyboard.instantiateViewControllerWithIdentifier("MyViewController") as ViewController self.presentViewController(VC1, animated:true, completion: nil) stefandouganhyde Calling presentViewController presents the view controller modally , outside the existing navigation stack; it is not contained by your UINavigationController

How to dismiss the current ViewController and go to another View in Swift

只谈情不闲聊 提交于 2019-11-27 15:59:37
问题 I am new to Swift and I want to know how to dismiss the current view controller and go to another view. My storyboard is like the following: MainMenuView -> GameViewController -> GameOverView. I want to dismiss the GameViewController to go to the GameOverView, not to the MainMenuView. I use the following code in my MainMenuView: @IBAction func StartButton(sender: UIButton) { let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard

Switching Views Programmatically in Swift

泪湿孤枕 提交于 2019-11-27 14:13:00
I am trying to switch to the second view by pressing the "feeling lucky" button. When I try out my simulator and press it, it just goes to a black screen. How could I fix this? @IBAction func FeelingLuckyPress(sender: UIButton) { let secondViewController:SecondViewController = SecondViewController() self.presentViewController(secondViewController, animated: true, completion: nil) } You can add a segue between the two scenes in your storyboard by control dragging from the view controller icon at the top of the first scene to the second scene: You can then select that segue and give it a unique

force landscape ios 7

[亡魂溺海] 提交于 2019-11-27 12:14:25
I've tried to following methods to force landscape on one my views: - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; } - (BOOL)shouldAutorotate{ return YES; } Neither did work. Note that I'm testing on the simulator and on an iPad. Thanks diogo.appDev Here is how I forced one of my views to be Landscape using NavigationViewController: Implemented this answer: https://stackoverflow.com/a/12662433/2394787 Imported message in the View

Swift presentViewController

时光毁灭记忆、已成空白 提交于 2019-11-27 10:50:37
I programatically have multiple View Controllers in an iOS Swift Project. I do not have the storyboards and would like to avoid them if possible. Is there a way to switch to another viewcontroller.swift file (We will call it view2.swift ) and have it be part of a function that a button calls? I have tried the following: let storyboard: UIStoryboard = UIStoryboard(name: "myTabBarName", bundle: nil) let vc: UIViewController = storyboard.instantiateViewControllerWithIdentifier("myVCID") as UIViewController self.presentViewController(vc, animated: true, completion: nil) The above works with

iOS Nested View Controllers view inside UIViewController's view?

隐身守侯 提交于 2019-11-27 10:12:22
Is it typically bad programming practice in iOS to have a nested view controller's view inside UIViewController's view? Say for instance I wanted to have some kind of interactive element that responds to user's touches, but only takes up maybe 25% of the screen. I suppose I would add this nested view controller to my UIViewController by saying something like: [self.view addSubview: nestedViewController.view]; No, this is generally good design, it helps keep your view controllers concise. However you should be using the view controller containment pattern, take a look at the following

Get the top ViewController in iOS Swift

99封情书 提交于 2019-11-27 09:18:29
I want to implement a separate ErrorHandler class, which displays error messages on certain events. The behavior of this class should be called from different other classes. When an error occurs, it will have an UIAlertView as output. The display of this AlertView should ALWAYS be on top. So no matter from where the Error gets thrown, the topmost viewController should display the AlertMessage (e.g. when an asynchronous background process fails, I want an error message, no matter what View is displayed in the foreground). I have found several gists which seem to solve my problem (see the code

App running slow after loading viewcontroller, then unload about 15-20 times

孤者浪人 提交于 2019-11-27 08:51:57
问题 Using: Xcode 4.6 Storyboards ARC Model segue to SecondViewController I have an app that has the main ViewController that loads a new veiwController when the device is rotated to the right. When the app starts everything works great. If I rotate the device, then back which unloads the secondview controller, about 15-20 times the app is very slugish. I have narrowed down that it only happenes when the seconed view controller is loaded and only when i rotate the device a nunmber of times. I also

Programmatically switching between tabs within Swift

回眸只為那壹抹淺笑 提交于 2019-11-27 07:44:35
I need write some code to switch the view to another tab when the iOS app starts (so, for example, the second tab is shown by default rather than the first). I'm new to Swift, and have worked out the following: The code should probably go in the override func viewDidLoad() function of the ViewController of the first tab. The following code shows the second ViewController, but not with the tab bar at the bottom (vcOptions is the second ViewController tab item: let vc : AnyObject! = self.storyboard.instantiateViewControllerWithIdentifier("vcOptions") self.showViewController(vc as