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];
}
You have to specify the name of the xib file you want to load (without extension):
Or if you create the GUI programmatically, just use a simple
init:Some additional remarks:
View2, I would assume it’s aUIViewsubclass. I’d rather call itViewController2.NSTimershould have a single argument (itself).EDIT:
With a storyboard you have to manually perform the seque you set up between the 2 views: