Loading a new .nib at startup - ios

In my project I added a new Cocoa Touch class along with its .nib file.I called the file ViewController. As a result three files were added to my project a
ViewController.h , ViewController.m and ViewController.nib. Now my project already had a default .nib file which I deleted.I then went to the properties settings and changed the main interface section to the name of my new nib file i.e ViewController.xib . I then added some content to my nib file however upon running the simulator my nib file content does not get displayed. Any suggestions on what I might be doing wrong. These are the files currently in the project. I am using Xcode 6.
Filename : ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#end
Filename : ViewController.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#end
FileName : AppDelegate.h
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
FileName : AppDelegate.m
#import "AppDelegate.h"
#interface AppDelegate ()
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
FileName: main.m
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Also at the end I get this
Application windows are expected to have a root view controller at the end of application launch
I am not sure if that is an error . Any suggestions on how I could resolve this issue ?

Try something like the following in your applicationDidFinishLaunching
self.window = [[UIWindow alloc] initWithFrame:
[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc]
initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;

You need to set the ViewController as your rootViewController in your AppDelegate.m. First you need to import ViewController.h then:
self.window.rootViewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
return YES;

Did you delete the app from your simulator or device before rebuilding from scrtach? Often time .xib changes do not take effect until you do.

Related

My iOS app plays audio in background, but when I press the home button the playback stops

I have a WebView based app that it's supposed to play YouTube videos' audio in the background while the device is Locked or the app is running in the background. By the way, the app uses the AVFoundation framework to handle all the audio related stuff.
Now, the problem is that the app pauses the audio playback when enters to background mode (When I lock the device or I press home), but the audio continues if I play it again from the control center. What I need is to avoid the app stopping the playback when entering background.
(Please remember that the app already has the ability to play audio in background.)
My code:
AppDelegate.h
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
AppDelegate.m
#import "AppDelegate.h"
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#interface AppDelegate ()
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(9.5);
NSError *setCategoryErr = nil;
NSError *activationErr = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&setCategoryErr];
[[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet UIWebView *webView;
#end
ViewController.m
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Load the url into the webview
NSURL *url = [NSURL URLWithString:#"http://relaxemy.com"];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end

How to solve the error 'No visible #interface for 'UIViewController' declares the selector ''

I am using Xcode 5
This is my AppDelegate.h file
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) UIViewController *viewController;
#end
This is my AppDelegate.m file
#import "AppDelegate.h"
#import "ViewController.h"
#implementation AppDelegate
#synthesize window = _window;
#synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
[self.viewController saveData];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[self.viewController loadData];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
This is my ViewController.h file
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
//some variables declared here
#interface ViewController : UIViewController <UIActionSheetDelegate, UINavigationBarDelegate, UIImagePickerControllerDelegate>{
//some outlets declared here
}
//some actions and - (void) declared here
- (NSString *) getFilePath;
- (void) saveData;
- (void) loadData;
#end
Beside the code [self.viewController saveData] and [self.viewController loadData] there's an error message:'No visible #interface for 'UIViewController' declares the selector 'saveData' and 'No visible #interface for 'UIViewController' declares the selector 'loadData'.
What should I do?
You should specify class of UIViewController in your AppDelegate.h file:
#property (strong, nonatomic) ViewController *viewController;
and add import statement in this file
#import "ViewController.h"
Your viewController is subclass of UIViewController class so there is not saveData/LoadData method.
The two method exists in your custom class - ViewController.
The solution is replace line in AppDelegate.h from:
#property (strong, nonatomic) UIViewController *viewController;
to:
#property (strong, nonatomic) ViewController *viewController;
or cast viewController to ViewController every time you call saveData/loadData
If the view controller in the app delegate is truly a ViewController object, then change the property to say so:
#property (strong, nonatomic) ViewController *viewController;
You will then also need the matching #class (.h) and #import (.m) statements.

Xcode error - unknown type name 'home'

this is my first question on stackoverflow.! Cheers.!
Please review my code from the link below. I have copy pasted appdelegate.h, appdelegate.m, viewcotroller.h&.m to a text document for reviewing purposes.
http://www.mediafire.com/view/85614p44t8eiqif/HomePageViewController.rtf
I will explain my problem in detail below.
I'm trying to recreate UICatalogue in a smaller scale all through code. I'm an app developement trainee. This is what I have done so far.
Keep in mind that my knowledge on Xcode and Objective-C is very limited. I'm using Xcode 5.1.1
I have created an instance variable (HPVC) for the Home Page view controller "HomePageViewController" in AppDelegate.h
I have set this HPVC as rootviewcontroller.
Declared and defined some instance variables.
*But I'm stuck in a loop from what I have searched so far.
I understand the importing has ended up in a loop. But I cant fix it.
Please check this and give me an answer. I can start my project If I can clear this obstacle.
Here is a screenshot of the error
http://www.mediafire.com/view/yjmwbb2dcb7rymd/Error.png
//
// AppDelegate.h
// NewUICatalogue1
//
// Created by Roshith Balendran on 18/04/14.
// Copyright (c) 2014 Roshith Balendran. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "HomePageViewController.h"
#interface AppDelegate : UIResponder <UIApplicationDelegate>
{
HomePageViewController *HPVC;
}
#property (strong, nonatomic) UIWindow *window;
#end
//
// AppDelegate.m
// NewUICatalogue1
//
// Created by Roshith Balendran on 18/04/14.
// Copyright (c) 2014 Roshith Balendran. All rights reserved.
//
#import "AppDelegate.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
HPVC=[[HomePageViewController alloc]initWithNibName:#"HomePageViewController" bundle:nil];
self.window.rootViewController=HPVC;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
//
// HomePageViewController.h
// NewUICatalogue1
//
// Created by Roshith Balendran on 18/04/14.
// Copyright (c) 2014 Roshith Balendran. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface HomePageViewController : UIViewController
//Background Images for all the Views.
#property(nonatomic,strong) UIImageView *HomePageBG;
#property(nonatomic,strong) UIImageView *Page1ButtonBG;
#property(nonatomic,strong) UIImageView *Page2ControlsBG;
#property(nonatomic,strong) UIImageView *Page3TextFieldBG;
#property(nonatomic,strong) UIImageView *Page4TextView;
#property(nonatomic,strong) UIImageView *Page5Images;
#property(nonatomic,strong) UIImageView *Page6Segments;
#property(nonatomic,strong) UIImageView *Page7Toolbar;
#property(nonatomic,strong) UIImageView *Page8Alerts;
#property(nonatomic,strong) UIImageView *Page9Transitions;
//Home Page Elements.
#property(nonatomic,strong) UILabel *lblHomePageHeader;
#property(nonatomic,strong) UILabel *lblHomePageWelcome;
#property(nonatomic,strong) UIButton *BtnPage1;
#property(nonatomic,strong) UIButton *BtnPage2;
#property(nonatomic,strong) UIButton *BtnPage3;
#property(nonatomic,strong) UIButton *BtnPage4;
#property(nonatomic,strong) UIButton *BtnPage5;
#property(nonatomic,strong) UIButton *BtnPage6;
#property(nonatomic,strong) UIButton *BtnPage7;
#property(nonatomic,strong) UIButton *BtnPage8;
#property(nonatomic,strong) UIButton *BtnPage9;
#property(nonatomic,strong) UIButton *BtnChangeBGColor;
//Future Update. Add Button to change all button colors in Home Page.
#end
//
// HomePageViewController.m
// NewUICatalogue1
//
// Created by Roshith Balendran on 18/04/14.
// Copyright (c) 2014 Roshith Balendran. All rights reserved.
//
#import "HomePageViewController.h"
#interface HomePageViewController ()
#end
#implementation HomePageViewController
#synthesize HomePageBG;
#synthesize Page1ButtonBG;
#synthesize Page2ControlsBG;
#synthesize Page3TextFieldBG;
#synthesize Page4TextView;
#synthesize Page5Images;
#synthesize Page6Segments;
#synthesize Page7Toolbar;
#synthesize Page8Alerts;
#synthesize Page9Transitions;
#synthesize lblHomePageHeader;
#synthesize lblHomePageWelcome;
#synthesize BtnPage1;
#synthesize BtnPage2;
#synthesize BtnPage3;
#synthesize BtnPage4;
#synthesize BtnPage5;
#synthesize BtnPage6;
#synthesize BtnPage7;
#synthesize BtnPage8;
#synthesize BtnPage9;
#synthesize BtnChangeBGColor;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//Home Page Background image added.
HomePageBG=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
HomePageBG.image=[UIImage imageNamed:#"Red"];
[self.view addSubview:HomePageBG];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#end
everything is correct but you forgot to import #import "HomePageViewController.h" on app delegate.m class

Compile Errors in untouched AppDelegate.m

I have been creating a simple example app to demonstrate playing sound files in IOS.
For this I have created a very simple XCode project with one view controller. However, although my AppDelegate.h and .m files have remained unedited I am getting strange parse issues in the AppDelegate.m.
On the line #Implimentation the compiler tells me its missing '#end'.
On the line -(BOOL) application: (UIApplication ) application didFinishLaunchingWithOptions: (NSDictionary) launch options it tells me Expected ';' after method prototype.
The issues seem to stem from the #import "ViewController.h" reference in the AppDelegate.m file. As when I remove this these two errors go away, and get replaced with Receiver 'ViewController' for class message is a forward declaration, which is what I would expect with a missing import.
This is an odd problem. I've built several IOS apps before but never encountered this issue. For background info the project was created as a Single View App in XCode 4. I have properly lined the IBOutlets and Properties of the ViewController.h to the XIB in interface builder. I have also added in the AudioToolbox framework in via the build phases > Link Library with Libraries feature.
Here is the delegete and view controller files files
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
AppDelegate.h
#import <UIKit/UIKit.h>
#class ViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
#end
ViewContoller.m
#import "ViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#interface ViewController ()
SystemSoundID pig;
SystemSoundID cow;
SystemSoundID sheep;
SystemSoundID chicken;
#end
#implementation ViewController
#Synthesize but_cow, but_pig, but_sheep, but_chicken;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString * cowSoundURL= [[NSBundle mainBundle] pathForResource:#"cow" ofType: #"mp3"];
NSString * pigSoundURL= [[NSBundle mainBundle] pathForResource:#"pig" ofType: #"mp3"];
NSString * sheepSoundURL= [[NSBundle mainBundle] pathForResource:#"sheep" ofType: #"mp3"];
NSString * chiickenSoundURL= [[NSBundle mainBundle] pathForResource:#"chicken" ofType: #"mp3"];
AudioServicesCreateSystemSoundID(cowSoundURL, &cow);
AudioServicesCreateSystemSoundID(pigSoundURL, &pig);
AudioServicesCreateSystemSoundID( sheepSoundURL, &sheep);
AudioServicesCreateSystemSoundID(chickenSoundURL, &chicken);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//====================================================
/**
Called when a button is pressed
**/
//====================================================
-(IBAction)buttonPressed:(id)sender
{
if (sender == but_cow)
{
AudioServicesPlaySystem(cow);
}
else if (sender == but_sheep)
{
AudioServicesPlaySystem(sheep);
}
else if (sender == but_pig)
{
AudioServicesPlaySystem(pig);
}
else if (sender == but_chicken)
{
AudioServicesPlaySystem(chicken);
}
}//===================================================
#end
ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (nonatomic, retain) IBOutlet UIButton * but_cow;
#property (nonatomic, retain) IBOutlet UIButton * but_pig;
#property (nonatomic, retain) IBOutlet UIButton * but_sheep;
#property (nonatomic, retain) IBOutlet UIButton * but_chicken;
-(IBAction)buttonPressed:(id)sender;
Thanks very much for taking the time to read this.
ViewController.h seems to be missing an #end
The line:
#import "ViewController.h"
will basically copy in the entire file, so if there is an error in ViewController.h, it will show up everywhere that file is imported as well.
You are not adding #end in viewcontroller.h

Ios blank screen

So i am doing a simple app.I have to nib files.I change the nib that loads first from viewController to firstController but it only shoes a blank screen. Here is my code:
MyAppDelegate.h
#import <UIKit/UIKit.h>
#class IpadAppViewController,FirstPageViewController;
#interface IpadAppAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
IpadAppViewController *viewController;
IBOutlet FirstPageViewController *firstController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet IpadAppViewController *viewController;
#property (nonatomic, retain) IBOutlet FirstPageViewController *firstController;
#end
MyAppDelegate.m
//
// IpadAppAppDelegate.m
// IpadApp
//
// Created by Stefan Andrei on 3/24/11.
// Copyright 2011 IMC. All rights reserved.
//
#import "IpadAppAppDelegate.h"
#import "IpadAppViewController.h"
#import "FirstPageViewController.h"
#implementation IpadAppAppDelegate
#synthesize window;
#synthesize viewController;
#synthesize firstController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
[self.window addSubview:firstController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
#end
Before doing [self.window addSubview:firstController.view], you should do
self.firstController = [[[FirstPageViewController alloc] initWithNibName:nil bundle:nil] autorelease];
If you've created FirstPageViewController together with the .xib, then that should be enough, otherwise you may need to pass the nib's name (without the .xib part) in initWithNibName:
Edit: added autorelease - the firstController property is retaining already.

Resources