Question

I am trying to load ViewController on button action but it does not load in iPhone.

- (IBAction)SubmitTapped:(id)sender
{
    if([txtName.text isEqualToString:@"User"])
    {
        NSLog(@"It is User");
    }
    else
    {
        NSString *soapMessage = @"";

        ThirdVC *thirdVCObj = [self.storyboard  instantiateViewControllerWithIdentifier:@"pushToThirdVC"];

        [self.navigationController pushViewController:thirdVCObj animated:YES];

        [self generalParsing:@"" :soapMessage];

        [sender setUserInteractionEnabled:NO];
    }
}

Note:- I have confirmed that my UIViewController class name ok & storyboard id is ok in code otherwise it will crash, When I make my First VC RootView of UINavigationController than it does not load my ThirdVC on click of SecondVC's button action but when I assign RootView of UINavigationController to my SecondVC then it loads my Third VC.

I tried placing my above Two lines of Push code to my Web Service parsing class but it does not load there also.

My viewDidLoad & viewWillAppear is being called, i set log in these methods.

I have searched all possible questions here on StackOverFlow but I did not find any solution.

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
enter code here

My Snap For StoryBoard

Était-ce utile?

La solution

First of all, your code is against to all "Cocoa Coding Guidelines"

I copied this code, to a new project and it works. The problem makes WebService parser, make sure that pushViewController:animated: is called from main thread.

Try this

    dispatch_async(dispatch_get_main_queue(), ^{
        NSString *soapMessage = @"";

        ThirdVC *thirdVCObj = [self.storyboard  instantiateViewControllerWithIdentifier:@"pushToThirdVC"];

        [self.navigationController pushViewController:thirdVCObj animated:YES];

        [self generalParsing:@"" :soapMessage];

        [sender setUserInteractionEnabled:NO];
    });
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top