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

  • SEARCH
  • Home
  • 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 9018813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:37:35+00:00 2026-06-16T04:37:35+00:00

I made a class called view2 which is a UIView Controller subclass and when

  • 0

I made a class called view2 which is a UIView Controller subclass and when i run the program the timer works fine but when it changes screens it just goes to black and not the picture I have on view2. This is the code I have on the .m of the opening view can anyone see where this is going wrong?

- (void)viewDidLoad
{
    randomMain = [NSTimer scheduledTimerWithTimeInterval:(2) target:self selector:@selector(onTimer) userInfo:nil repeats:NO];

    [super viewDidLoad];
}


-(void)onTimer{

    view2 *second= [[view2 alloc] initWithNibName:nil bundle:nil];
    [self presentViewController:second animated:YES completion:nil];

}
  • 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-16T04:37:36+00:00Added an answer on June 16, 2026 at 4:37 am

    You have to specify the name of the xib file you want to load (without extension):

    view2 *second = [[view2 alloc] initWithNibName:@"MyView2Xib" bundle:nil];
    

    Or if you create the GUI programmatically, just use a simple init:

    view2 *second = [[view2 alloc] init];
    

    Some additional remarks:

    • Class names should always start with a capital letter, to distinguish them from variables.
    • It’s a good idea to include part of the superclass’ name in your subclass’ name. If I saw a class called View2, I would assume it’s a UIView subclass. I’d rather call it ViewController2.
    • There is no need to put the interval in parenthesis.
    • The action of an NSTimer should have a single argument (itself).

    EDIT:

    With a storyboard you have to manually perform the seque you set up between the 2 views:

    - (void)onTimer {
        [self performSegueWithIdentifier:@"YourSegueIdentifier" sender:self];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a class which looks something like. class NewInt: def __init__(self, x,y): self.holders
I have made an class which conforms to the NSCoding protocol and does all
How can I unit test my NSURLConnection delegate? I made a ConnectionDelegate class which
I have made my own exception class which derives from runtime_error and is getting
I have made an application which calls the phone's contact list but i want
I've got a Table View Controller object in my Storyboard, but I've made it
I made a program in which I wanted to manually update the Data Grid
I have made a helper class called Navigation that gets used on every page
I made a program which uploads a video to an asp.net server. Then I
I've made a small example with a Person class, which contains a list of

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.