logo
down
shadow

self.navigationController? is nil when pushing from a objective-c viewController to a Swift ViewController


self.navigationController? is nil when pushing from a objective-c viewController to a Swift ViewController

By : Tedxxx
Date : November 21 2020, 07:31 AM
it helps some times If I call for the navigationController in viewDidAppear() it works fine. My problem was that I called for it in viewDidLoad() and it returned nil.
code :


Share : facebook icon twitter icon
Pushing a new ViewController from a ViewController that is embedded in a TabBarController and NavigationController

Pushing a new ViewController from a ViewController that is embedded in a TabBarController and NavigationController


By : sHipar
Date : March 29 2020, 07:55 AM
around this issue if your using storyboard segue then better use prepareForSegue: method and pass the person object.
code :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Cell was clicked");
    [self performSegueWithIdentifier:@"yourSegueIdentifier" sender:self];

}

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"yourSegueIdentifier" ]) {

         NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
         Person *person = [self.tableData objectAtIndex:indexPath.row];
         NSLog(@"Person selected: %@", person);
         SingleContactViewController *singleContactViewController = segue.destinationViewController;
         singleContactViewController.person = person; // create person object as a property in SingleContactViewController and assign the person object.
    NSLog(@"created singlecontactviewcontroller");

   } 

}
NavigationController is showing another view controller instead of pushing viewcontroller

NavigationController is showing another view controller instead of pushing viewcontroller


By : Windrivder
Date : March 29 2020, 07:55 AM
Why does a ViewController not declare when it contains a NavigationController when pushing a segue?

Why does a ViewController not declare when it contains a NavigationController when pushing a segue?


By : user2042505
Date : March 29 2020, 07:55 AM
it helps some times Use navigationController.topViewController instead of navigationController.viewControllers[0].
Try deleting the second view controller files from Xcode (without moving them to the Trash) and then re-adding them. Also, clean the project before compiling again.
Pushing a DialogViewController onto a ViewController onto NavigationController stack gives 2 pages

Pushing a DialogViewController onto a ViewController onto NavigationController stack gives 2 pages


By : user3232600
Date : March 29 2020, 07:55 AM
will help you I fixed it in the following way:
I created a custom class for my TableViewController (containing a TableView with static cells):
code :
partial class MainMenuTableViewController : UITableViewController
{
    public MainMenuTableViewController (IntPtr handle) : base (handle)
    {
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        this.TableView.Delegate = new MainMenuTableViewDelegate (this); //this is the important part. Here I set a custom delegate class for the TableView. I pass the current TableViewController as a parameter in the constructor so I can call the NavigationController from the delegate class to push my custom MonoTouch DialogViewController onto the navigation stack
    }
}
    public class MainMenuTableViewDelegate : UITableViewDelegate
    {
        private UITableViewController _parentController;

        public MainMenuTableViewDelegate(UITableViewController parentController) : base()
        {
            _parentController = parentController;
        }

        public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            if (indexPath.Row == 2) {                   
                _parentController.NavigationController.PushViewController (new AccountDialogViewController(), true);
            }
        }
    }
public class AccountDialogViewController : DialogViewController
{
    public AccountDialogViewController () : base(new RootElement("Account settings"), true)
    {               
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        var btnUpdatePassword = UIButton.FromType(UIButtonType.RoundedRect);
        btnUpdatePassword.SetTitle("Save new password", UIControlState.Normal);
        btnUpdatePassword.Frame = new RectangleF(0, 0, 320, 44);
        btnUpdatePassword.TouchUpInside += delegate(object sender, EventArgs e) {
            var alert = new UIAlertView("Test", "msg", null, "Cancel", null);
            alert.Show();
        };
        Root.Add(new Section ("General") {
            new EntryElement("Username", "type...", "Test"),
            new EntryElement("E-mail", "type...", "Test"),
            new RootElement ("Change password") {
                new Section (null, btnUpdatePassword) {
                    new EntryElement("New password", null, null, true),
                    new EntryElement("Confirm", null, null, true)               
                }
            },
            new StringElement ("Logout", delegate {
                var alert = new UIAlertView("Are you sure?", "Tapping Yes will log you out of your account", null, "Cancel", "Yes");
                alert.Show();
            })
        });
    }
}
Passing data from Objective-C Viewcontroller to Swift ViewController

Passing data from Objective-C Viewcontroller to Swift ViewController


By : Anza Power
Date : March 29 2020, 07:55 AM
it should still fix some issue The Solution to your problem is like that :
First in your Swift Controller add the @Objc before the class keyword like that :
code :
@objc class ViewController: UIViewController
public var myValue:String  = ""
#import "TargetName-Swift.h"
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"];
vc.myValue = @"Hello";
Related Posts Related Posts :
  • Convert from NStimeInterval to CMTime accurately
  • How can I continue my count from the correct spot once I load the saved count?
  • instance method 'connect:' not found (return type defaults to 'id'
  • Does an object initialize automatically if it is the synthesized property of another object?
  • What reasons are there to pass an argument to an initializer in objective C?
  • NSLogging UILabel's text outputs null
  • undefined reference to '__objc_class_name_Fraction'
  • Move UIView above UITableView when user Scrolls Down
  • adding object to nsmutablearray with custom delegate function giving error
  • Cocoa editing NSBezierPath
  • Perform a action on specific time using Parse
  • Objective-C: How to convert json value to BOOL?
  • How to make an int counter for the days
  • Assigning Label Value with Selected Table View Cell
  • SpriteKit - Preloader using GCD
  • Can dependency injection like Typhoon replace multiple singletons?
  • Objective C - How to determine if a folder is a package?
  • How can one draw a background in the elastic portion of an NSScrollView?
  • A solution for my issue with sending some info from an array to Parse
  • Swift Extension fails adding overloaded methods to Objective-C class
  • Determine if key is incorrect with CCCrypt kCCOptionPKCS7Padding-Objective C
  • PQgetResult always returns NULL
  • Where to add subViews that I want floating in an NSScrollView using AutoLayout?
  • 'User' in 'User-defined classes'
  • How to get value of a key in NSDictionary?
  • Adding Border Line to UITableView in StoryBoard
  • Mac App Storyboard - Access Document in NSViewController
  • Objective c, reposition a view above the keyboard in one single animation
  • Dismiss modal segue
  • Error message is saying my data is NULL - NSKeyedUnArchiver - I've followed all the steps - still won't work
  • Remove apostrophe in CFStringTransform results
  • Label showing wrong values while NSLog shows the right ones in SpriteKit
  • How to work with locally modified Cocoapod which don't include podspec?
  • What does kCGWindowSharingState actually do?
  • It is possible to copy a CFTypeRef?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org