Hi, I have a simple questions view I need to load when a user taps on the selected row in the previous root view, but my view that gets loaded is just blank:
When it should look like this with the nav bar at the top:
Here is my code: Questions.h:
and Questions.m:
I know the answer will seem very easy to someone here, so any help is appreciated! I need to get this working by Friday 

When it should look like this with the nav bar at the top:

Here is my code: Questions.h:
Code:
#import <UIKit/UIKit.h>
@interface Questions : UIViewController
{ UIView *View;
int currentQuestionIndex;
// The model objects
NSMutableArray *questions;
//The view objects
IBOutlet UILabel *questionField;
}
@property (nonatomic, retain) UIView *view;
- (IBAction)showQuestion:(id)sender;
@end
and Questions.m:
Code:
#import "Questions.h"
@implementation Questions
@synthesize view;
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation !=
UIInterfaceOrientationPortraitUpsideDown);
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Test"; }
-(id)init
{
// Call the init method implemented by the superclass
[super init];
// Create two arrays and make the pointers point to them
questions = [[NSMutableArray alloc] init];
// Add questions and answers to the arrays
[questions addObject:@"Where do you think our country lacks?"];
[questions addObject:@"Who do you feel is the most popular person in the world? Why?"];
[questions addObject:@"Should the government bail out failing companies?"];
// Return the address of the new object
return self;
}
- (IBAction)showQuestion:(id)sender
{
// Step to the next question - just to keep things simple
// to focus on the iOS elements of the programming,
// we will start with the "second" question in the list.
currentQuestionIndex++;
// Am I past the last question?
if (currentQuestionIndex == [questions count]) {
// Go back to the first question
currentQuestionIndex = 0;
}
// Get the string at that index in the questions array
NSString *question = [questions objectAtIndex:currentQuestionIndex];
// Log the string to the console
NSLog(@"displaying question: %@", question);
//Display the string in the question field
[questionField setText:question];
}
- (void)dealloc {
[view release];
[super dealloc];
}
@end
Last edited: