Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:18:54+00:00 2026-06-09T21:18:54+00:00

I want to be able to open a ViewController from a different class. So

  • 0

I want to be able to open a ViewController from a different class. So I could simply call it to open a view wherever I need it.

So I have this setup in the class that holds the code:


+ (void)openCalcView: (NSString *)nameOfView {

UIViewController *controller;

if ([nameOfView isEqualToString:@"Tax"]) {

    controller = [[TAXViewController alloc]initWithNibName:@"TAXViewController" bundle:nil];


}else if ([nameOfView isEqualToString:@"Rent"]){

    controller = [[RENTViewController alloc]initWithNibName:@"RENTViewController" bundle:nil];

}

controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:controller animated:YES completion:nil];
[controller release];

}

But [self presentViewController:controller animated:YES completion:nil]; gives me a warning:

Class method '+presentViewController:animated:completion:' not found (return type defaults to 'id')

I can call simple things like NSLog through this, from any class. But this doesn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:18:56+00:00Added an answer on June 9, 2026 at 9:18 pm

    Because openCalcView is a Class method, there is no UIViewController instance (i.e. no [self presentViewController:] method).

    You’ll need to also pass a UIViewController to this class method, something like this:

    + (void)openCalcView: (NSString *)nameOfView fromViewController:(UIViewController *)controller { 
    
        UIViewController *newController; 
    
        if ([nameOfView isEqualToString:@"Tax"]) { 
    
            newController= [[TAXViewController alloc]initWithNibName:@"TAXViewController" bundle:nil]; 
    
    
        }else if ([nameOfView isEqualToString:@"Rent"]){ 
    
            newController= [[RENTViewController alloc]initWithNibName:@"RENTViewController" bundle:nil]; 
    
        } 
    
        newController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
        [controller presentViewController:newController animated:YES completion:nil]; 
        [newController release]; 
    
    } 
    

    the controller parameter represents the UIViewController that is opening the new view controller

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want: To be able to open a form, select an item from a
I want to stop outgoing call and open the application. The app is able
I want to be able to open/view a image (.jpg) without locking the file.
This was my original question: I want to be able to open a pdf
I have a list of companies and I want to be able to open
I want to be able to open a pdf file from my application without
I want to be able to open Android's stock Wifi Settings screen from my
I want to be able to open up the JButton class and see the
I want to be able to open a file chooser dialog, from which I
My need is simple - I want to be able to open my text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.