I am creating an iPad app using XCode 4 and Storyboards. I have a TabBar Controller with two UIViews. I have my iPad app and Kal in a workspace. I am trying to copy some of the Kal sample code to get the calendar to display. This is what I have copied (with minimal changes):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// initialization...
KalViewController *kal = [[KalViewController alloc] init];
kal.title = @"Saori";
// configuration
kal.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Today" style:UIBarButtonItemStyleBordered target:self action:@selector(showAndSelectToday)];
kal.delegate = self;
EventKitDataSource *dataSource = [[EventKitDataSource alloc] init];
kal.dataSource = dataSource;
// Setup the navigation stack and display it.
navController = [[UINavigationController alloc] initWithRootViewController:kal];
[window addSubview:navController.view];
[window makeKeyAndVisible];
return YES;
}
On the last 3 lines (Setup the navigation stack and display it) I am getting errors such as undeclared “navController”, and “window”. I don’t believe the 3 lines belong in this app because I have the TabBar Controller, but I don’t know what to replace them with to display the calendar.
How do I take my existing code and display the Kal calendar in the TabBar Controller’s UIView?
You are right that you don’t need the bottom 3 lines, but in fact, you don’t need any of these lines. If you’re using StoryBoards you should be able to setup your view stack entirely from there. The only thing you might need is to add the EventKit datasource to your Kal view controller, but you can do that from
[KalViewController viewDidLoad:]. Your view stack should look like this:Window -> Tab Bar Controller -> Nav Bar Controller -> Root View Controller
So by adding your Nav Bar view controller directly to the window, you’re skipping the Tab bar controller entirely.