logo
down
shadow

presentViewController not working in Swift


presentViewController not working in Swift

By : user2951847
Date : November 18 2020, 03:49 PM
this will help The presentViewController is the instance method of UIViewController class. So you can't access it on your function file like this.
You should change the function like:
code :
func showAlert(alert : String, viewController : UIViewController) -> Void
{
   if(alert == "pleaseAssessAlert")
   {
       let pleaseAssessAlert = UIAlertController(title: "Welcome!", message: "If this is your firs time, I encourage you to use the Speed Assessment Tool (located in the menu) to figure which of you fingers is fastest!", preferredStyle: .Alert)
       //ok button
       let okButtonOnAlertAction = UIAlertAction(title: "Done", style: .Default)
       { (action) -> Void in
            //what happens when "ok" is pressed
       }
       pleaseAssessAlert.addAction(okButtonOnAlertAction)
       viewController.presentViewController(pleaseAssessAlert, animated: true, completion: nil)
   }
   else
   {
       println("Error calling the alert function.")
   }    
}


Share : facebook icon twitter icon
Presenting view with presentViewController:animated:completion: not working when presentViewController:animated:completi

Presenting view with presentViewController:animated:completion: not working when presentViewController:animated:completi


By : Joe Lu
Date : March 29 2020, 07:55 AM
Does that help Don't Present it in viewDidLoad , instead you can load it in viewDidAppear method.
code :
-(void)viewDidAppear:(BOOL)animated
{
    UINavigationController *navController = [self.storyboard instantiateViewControllerWithIdentifier:@"someViewController"];
    [self presentViewController:navController animated:NO completion:nil];
}
Swift presentViewController

Swift presentViewController


By : Brian Dunnigan
Date : March 29 2020, 07:55 AM
should help you out 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? , Try this:
code :
let vc = ViewController() //change this to your class name
self.presentViewController(vc, animated: true, completion: nil)
self.present(vc, animated: true, completion: nil)
Swift presentViewController does not have the navigation bar

Swift presentViewController does not have the navigation bar


By : ZeroVirus999
Date : March 29 2020, 07:55 AM
will help you You can use an Navigation Controller, if you need to handle different ViewControllers.
To add a Navigation Controller, you can simple use the Storyboard Editor.
presentViewController has no navigationController swift

presentViewController has no navigationController swift


By : Michael Coyle
Date : March 29 2020, 07:55 AM
I wish did fix the issue. SOLUTION THAT WORKED FOR ME
I don't know why, but when you use the presentViewController you have to define a new(?) root for your navigationController.
code :
if let storyboard:UIStoryboard = UIStoryboard(name: "myStoryboard", bundle: nil) {
        if let vc = storyboard.instantiateViewControllerWithIdentifier("MyViewController") as? MyViewController {
            if let navController:UINavigationController = UINavigationController(rootViewController: vc) {
                dispatch_async(dispatch_get_main_queue()) {
                    self.presentViewController(navController, animated:true, completion: nil)
                }
            }
        }
    }
    let storyboard = UIStoryboard(name: UIConstants.Storyboards.registration, bundle: nil)
    if let vc = storyboard.instantiateViewController(withIdentifier: "YourViewControllerIdentifier") as? YourViewController {

        let navigationController = UINavigationController(rootViewController: vc)
        DispatchQueue.main.async {
            navigationController.present(vc, animated: true)
        }
    }
Swift presentViewController completion block working only in debug not called in release

Swift presentViewController completion block working only in debug not called in release


By : Prasanth AK
Date : March 29 2020, 07:55 AM
around this issue It looks a Swift compiler bug (at least version 1.1) discussed here: https://github.com/ReactiveCocoa/ReactiveCocoa/issues/1632
In a release build, closures are not invoked sometimes especially when they are sequenced like:
Related Posts Related Posts :
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • Web services issue on POST method
  • Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass
  • Swift can't send URLRequest at all?
  • No Provisiong profiles with a valid signing identity were found and Failed to locate or generate matching signing assets
  • iOS: how to set httponly flag for NSHTTPCookie
  • How to get the mac address of a beacon in objective-c without knowing its UUID, major and minor values?
  • tableView is not showing data from JSON in swift
  • iTunes reject app for date of birth
  • SWIFT reporting "Extra argument in call" - works in Playground
  • save data depending on passed value in swift
  • webview not showing on full Screen of iphone 6
  • Location Notification's based on Latest iOS Feature
  • Adjusting Height of UITableViewCell
  • How to show five digit unicode in iphone
  • unwind doesn't work
  • Confusion about coordinates, frames & child nodes in SpriteKit on iOS?
  • If Statements not being recognized by Xcode
  • readonly property in RubyMotion
  • 'No available types for source 1' when the app runs on my device(IPhone 6) swift
  • IOS:Remove view when clicked in background
  • Removing "\" from URL in iOS Swift
  • iOS - Send an email automatically (NOT from user's account)
  • The usage of NSNotificationCenter in the relationship of parent and children
  • When do Apple auto-renewable subscriptions renew?
  • Unknown large spacing between x-axis label and base of plot in core-plot
  • How do I change the displayed time format after NSTimer is initiated?
  • Swift JSON breaks when [ ] are used
  • Secure Memory For Swift Objects
  • didSelectItemAtIndexPath doesn't work normally
  • Swift Documentation Comments
  • Is there a simple way to assign a value only once(first time) inside a loop/repeatedly running method?
  • Play sound in while app in background
  • If I have an embedded unrestricted webview, does that mean I have third-party content?
  • UITapGestureRecognizer on UIScrollView
  • App does not respond to hardware volume changes on iPad
  • troubleshoot asp.net web app on iOS
  • What size should my tab bar item icons be?
  • Parse.com Facebook authorize never calls completion handler
  • Implementing iAds on a SceneKit view
  • UIAccessibility and Apple Pay voice-over interaction issue
  • Getting objectForKeyedSubscript unrecognized selector when parsing data in table view
  • Execute action when back bar button of UINavigationController is pressed
  • iOS Table View - Set tag on cell or label?
  • Preferred approach for changing UITableViewCell content based on cell width
  • NSDateformatter dateFromString AnyObject
  • Type specifier for NSMutableArray?
  • iOS7 slideout drawer draggable bug
  • Fetch Core Data entity with a filtered set of child elements based on a property
  • UILabel AutoResize Swift
  • Swift - Selecting cells when having multiple custom cell-classes
  • Table View Cell Prototype from Storyboard not initializing subviews
  • Best way to implement view like map
  • Adding a tap gesture to a UIImageView to change a UILabel?
  • Minimum OS X and xcode requirements for ios 8.1 development
  • Changing the text of the Cancel button in the default TouchID dialog
  • iOS timing between taps
  • Swift: How do I link an action to a view inside of a tableViewCell?
  • Value for frame.size.height is always the same regardless of height of view
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org