Please visit the new Mac-Forums Facebook page:
https://www.facebook.com/macforums1




Results 1 to 8 of 8
  1. #1
    Question UIAlertView in AppDelegate have to call Method in ViewController
    Hi,

    i have a method called perform4 in the ViewController.m

    Code:
    -(void) perform4
    {
     NSLog(@"perform4");
     UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    ViewController4 *view4 = (ViewController4 *) [mainStoryBoard instantiateViewControllerWithIdentifier:@"ViewController4"];
    
    [self.view removeFromSuperview];
    [self release];
    
    self.view = view4.view;
    [self release];
    }
    this Method has to be called from my AppDelegate.m with this AlertView Button

    Code:
    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
     if(buttonIndex==0)
    {
       NSLog(@"Button 0");
    
      
      //EVERYTHING I WILL PUT HERE DO NOT WORK OR MAKE A CRASH :/
      //like
      // ViewController *view1 = [[ViewController alloc]init];
      // [view1 perform4];
      // WHY DO THIS DONT WORK? 
    
    }
    Thanks

  2. #2
    UIAlertView in AppDelegate have to call Method in ViewController
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    8
    Your code is very confusing, I haven't used storyboards myself yet, so I will have accept your storyboard code is correct.

    But to start with you are missing a curly brace in the second code snippet, try indenting your
    code sections, so that you can see the different curly braces line up like this.

    Code:
    - (void)myMethod
    {
    	if (thisIsTrue) {
    	
    	}
    }
    Secondly you are releasing yourself twice in the first code snippet for some reason.

    Sorry I can't help you much with this at the moment, but your code is very confusing, you
    may have to be more specific with the details of your class files, and how they interact.

    Regards Mark

  3. #3
    thanks, but this isn't what i asked for, i need only to load ViewController4 :/ but how ?

  4. #4
    Quote Originally Posted by poke View Post
    it works, when i call it from the viewcontroller.m , but not when i try to call it from the appdelegate.m - i need to know how to call it, to make everything work

    can you help me please?

    ok i realized this with

    Code:
    self.window.rootViewController.view = view4;
    [self.window makeKeyAndVisible];
    but i have now the problem to switch back, while

    Code:
     
    self.window.rootViewController.view = view;
    [self.window makeKeyAndVisible];
    let crash my app

  5. #5
    UIAlertView in AppDelegate have to call Method in ViewController
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    8
    You still have'nt explained how the different class files interact in your project, so where
    only going to be guessing here, also your mixing dot notation with square bracket synatx,
    also you seem to have an ivar or property called view, you should probably change this to
    another as it might be causing a conflict with your view controllers and windows own
    properties also called view.

    Try writing it this way and see what happens.

    Code:
    [[self window] setRootViewController: view4];
    only a guess.

    Regards Mark

  6. #6
    Mark, your guessing works, it works that what i have done before ...

    i need now to know how to set back the RootViewController to view1 the original RootViewController and all is done

    what do you mean how the diffrent class files interact in your project? i will try to explain you everything hoping i will sleep again calm at night ... i'm disperated really

  7. #7
    UIAlertView in AppDelegate have to call Method in ViewController
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    8
    What I meant by how your project files interact is, how many view controllers and there names, how many windows, and where are you making these method calls from, without
    this info it makes it very hard for someone to help you.

    Can you not make the exact same method call I posted on the veiw1 instead of of veiw4?

    Mark

  8. #8
    ok mark, this night i figured out, i made a segue to this viewcontroller from the rootviewcontroller and everything is working fine ... thanks so much for your help...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to from viewController to NavigationController?
    By fabiohenrique in forum iOS Development
    Replies: 0
    Last Post: 07-14-2013, 08:38 AM
  2. Need Suggestions Naming ViewController
    By Loon3y in forum iOS Development
    Replies: 0
    Last Post: 12-03-2012, 07:59 AM
  3. How can I call another viewController through an event?
    By lftapajos in forum iOS Development
    Replies: 0
    Last Post: 02-01-2012, 10:26 AM
  4. Help: Unable to receive Voice Call during Data (EDGE) call ..
    By muneeb.ansari in forum iOS and Apps
    Replies: 0
    Last Post: 04-13-2010, 03:13 AM
  5. Objective C call main method
    By ncohen in forum macOS - Development and Darwin
    Replies: 1
    Last Post: 06-23-2009, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •