Allocation of several sounds - iphone

I'm not sure if I wrote this code well (get clicks on touching buttons rapidly):
#import "iEngineRoomAppDelegate.h"
#import "iEngineRoomViewController.h"
#import "SoundEffect.h"
#implementation iEngineRoomAppDelegate
#synthesize window;
#synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
[self setupSounds];
}
- (void)setupSounds {
NSBundle *mainBundle = [NSBundle mainBundle];
timbal_big_Sound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:#"timbal_big" ofType:#"caf"]];
timbal_sm_Sound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:#"timbal_sm" ofType:#"caf"]];
}
- (IBAction)timbal_big: (id)sender {
SoundEffect *currentSoundEffect= timbal_big_Sound;
[currentSoundEffect play];
}
- (IBAction)timbal_sm: (id)sender {
SoundEffect *currentSoundEffect= timbal_sm_Sound;
[currentSoundEffect play];
}
- (void)dealloc {
[timbal_big_Sound release];
[timbal_sm_Sound release];
[viewController release];
[window release];
[super dealloc];
}
#end

Memory management of the SoundEffect objects is right, if you meant that.

Related

iPhone Objective C - can't display new view

I'm finding it difficult to get started in Objective-C.
I'm executing the following code when a button is clicked:
NSLog(#"hi");
MainMenuDriver *mainMenuDriver= [[MainMenuDriver alloc] initWithNibName:nil bundle:nil];
[[self navigationController]pushViewController:mainMenuDriver animated:YES];
I can see "hi" in the console when I hit the button, it's just that the view should change to MainMenuDriver. But nothing happens!
Please help!
As per request for more code:
MainMenuDriver.h:
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#interface MainMenuDriver : UIViewController <UINavigationControllerDelegate,CLLocationManagerDelegate>{
IBOutlet UIButton *photos;
IBOutlet UIButton *profile;
IBOutlet UISwitch *onOffline;
IBOutlet UILabel *label1;
NSTimer *uploadGPS_timer;
CLLocationManager *lm;
NSString *lat;
NSString *lng;
}
#property(nonatomic,retain) UIButton *photos;
#property(nonatomic,retain) UIButton *profile;
#property(nonatomic,retain) UISwitch *onOffline;
#property(nonatomic,retain) UILabel *label1;
#property (nonatomic,retain) NSTimer *uploadGPS_timer;
#property(nonatomic,retain) NSString *lat,*lng;
-(IBAction)showMessages:(id)sender;
-(IBAction)showFriends:(id)sender;
-(IBAction)showPhotos:(id)sender;
-(IBAction)showProfile:(id)sender;
-(IBAction)switchSwitched:(id)sender;
-(void)uploadGPS_tick:(NSTimer*)timer;
#end
MainMenuDriver.m
#import "MainMenuDriver.h"
#import "ASIFormDataRequest.h"
#import "JoeMaxiViewController.h"
#import "Photos.h"
#import "Profile.h"
#implementation MainMenuDriver
#synthesize messages,profile,photos,friends,label1;
#synthesize onOffline;
#synthesize uploadGPS_timer;
#synthesize lat,lng;
-(IBAction)showPhotos:(id)sender{
[self.navigationItem setBackBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:#"Back" style:UIBarButtonItemStylePlain target:nil action:nil]];
Photos *x= [[Photos alloc] initWithNibName:nil bundle:nil];
[[self navigationController]pushViewController:x animated:YES];
}
-(IBAction)showProfile:(id)sender{
[self.navigationItem setBackBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:#"Back" style:UIBarButtonItemStylePlain target:nil action:nil]];
Profile *x= [[Profile alloc] initWithNibName:nil bundle:nil];
[[self navigationController]pushViewController:x animated:YES];
}
-(void)logout:(id)sender{
if([uploadGPS_timer isValid]){
[uploadGPS_timer invalidate];
}
[lm release];
//[uploadGPS_timer release];
[self.navigationController popViewControllerAnimated:NO];
/*NSString *urlStr=[[NSString alloc] initWithFormat:#"http://www.prestocab.com/driver/ajax/logout.php"];
NSURL *url=[NSURL URLWithString:urlStr];
__block ASIFormDataRequest *request=[[ASIFormDataRequest alloc ]initWithURL:url];
[request setDelegate:self];
[request setCompletionBlock:^{
NSString *response=[request responseString];
NSLog(#"%#",response);
}];
[request setFailedBlock:^{
}];
[request startAsynchronous];*/
}
-(IBAction)switchSwitched:(id)sender{
if(onOffline.on){
[label1 setText:#"For Hire"];
[label1 setTextColor:[UIColor colorWithRed:0.0 green:0.8 blue:0.0 alpha:1.0]];
uploadGPS_timer=[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:#selector(uploadGPS_tick:) userInfo:nil repeats:YES];
[self uploadGPS_tick:nil];
}else{
[label1 setText:#"Engaged"];
[label1 setTextColor:[UIColor colorWithRed:0.8 green:0.0 blue:0.0 alpha:1.0]];
if([uploadGPS_timer isValid]){
[uploadGPS_timer invalidate];
}
}
}
-(void)uploadGPS_tick:(NSTimer*)timer{
if(!lat || !lng){
//do nothing
}else{
NSString *urlStr=[[NSString alloc] initWithFormat:#"http://www.prestocab.com/driver/ajax/updateCoords.php"];
NSURL *url=[NSURL URLWithString:urlStr];
__block ASIFormDataRequest *request=[[ASIFormDataRequest alloc ]initWithURL:url];
[request setPostValue:lat forKey:#"lat"];
[request setPostValue:lng forKey:#"lng"];
NSLog(#"EOH: %#",lat);
[request setDelegate:self];
[request setCompletionBlock:^{
NSString *response=[request responseString];
NSLog(#"%#",response);
//do nothing
}];
[request setFailedBlock:^{
//NSError *error =[request error];
//do nothing
}];
[request startAsynchronous];
}
}
-(void)locationManager:(CLLocationManager*) manager didUpdateToLocation:(CLLocation *) newLocation fromLocation:(CLLocation*) oldLocation{
lat=[[NSString alloc]initWithFormat:#"%g",newLocation.coordinate.latitude];
lng=[[NSString alloc]initWithFormat:#"%g",newLocation.coordinate.longitude];
NSLog(#"%#,%#",lat,lng);
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
self.navigationItem.title=#"PrestoCab";
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:#"Logout" style:UIBarButtonItemStylePlain target:self action:#selector(logout:)];
self.navigationItem.rightBarButtonItem = anotherButton;
[anotherButton release];
//GPS
lm=[[CLLocationManager alloc] init];
if([CLLocationManager locationServicesEnabled]){
lm.delegate=self;
lm.desiredAccuracy=kCLLocationAccuracyBest;
lm.distanceFilter=30.0f;
[lm startUpdatingLocation];
}
//[self check4messages_tick:nil]; //want to start immediately, not in 10/40 seconds' time
[self uploadGPS_tick:nil];
//check4messages_timer=[NSTimer scheduledTimerWithTimeInterval:40.0 target:self selector:#selector(check4messages_tick:) userInfo:nil repeats:YES];
uploadGPS_timer=[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:#selector(uploadGPS_tick:) userInfo:nil repeats:YES];
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
if([uploadGPS_timer isValid]){
[uploadGPS_timer invalidate];
}
}
-(void)dealloc{
[super dealloc];
[uploadGPS_timer release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
Also, here is
MyClassViewController.h:
#import <UIKit/UIKit.h>
#interface MyClassViewController : UINavigationController{
IBOutlet UIButton *passenger;
IBOutlet UIButton *driver;
}
#property (nonatomic,retain) UIButton *passenger;
#property (nonatomic,retain) UIButton *driver;
-(IBAction) passengerClicked:(id)sender;
-(IBAction) driverClicked:(id)sender;
#end
and MyClassViewController.m:
#import "MyClassViewController.h"
#import "MainMenuDriver.h"
#implementation MyClassViewController
#synthesize passenger;
#synthesize driver;
-(IBAction)passengerClicked:(id)sender{
NSLog(#"passenger");
}
-(IBAction)driverClicked:(id)sender{
NSLog(#"driver");
MainMenuDriver *mainMenuDriver= [[MainMenuDriver alloc] initWithNibName:nil bundle:nil];
[[self navigationController]pushViewController:mainMenuDriver animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#end
I can see a couple of things:
Your nib file's name is different from the name of your class. If you put nil, the UIViewController will try to load a nib file with the UIViewController's name. Your UIViewController can be MainMenuDriver but your nib file name can be MainMenuDriverNibFileName.nib
[self navigationController] is nil.
For this, do the following:
NSLog(#"hi");
if([self navigationController]){
MainMenuDriver *mainMenuDriver= [[MainMenuDriver alloc] initWithNibName:nil bundle:nil];
[[self navigationController]pushViewController:mainMenuDriver animated:YES];
}
else{
NSLog(#"Houston we have a problem");
}
Update 1:
So, its nil, what you can do is the following:
Quick and Dirty:
[self presentViewController:mainMenuDriver animated:YES];
Instead of UIViewController switch to a UINavigationController.

XIB file does not appear

Have created a tab application and created the first XIB file which includes a date picker and round rect button. Problem is when I run it, nothing displays in the simulator. Only get one warning for "incomplete implementation" for BidDatePickerViewController in the implementation file which I have commented out.
Here is the code for the files:
ViewController header:
#import <UIKit/UIKit.h>
#interface BiDDatePickerViewController : UIViewController
#property (strong, nonatomic)IBOutlet UIDatePicker *datePicker;
-(IBAction):buttonPressed;
#end
ViewController implementation:
#import "BiDDatePickerViewController.h"
#implementation BiDDatePickerViewController // Incomplete implementation
#synthesize datePicker;
-(IBAction)buttonPressed
{
NSDate *selected = [datePicker date];
NSString *message = [[NSString alloc]initWithFormat:#"The date and time selected is: %#", selected];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Date And Time Selected"
message:message
delegate:nil
cancelButtonTitle:#"Yes, I did."
otherButtonTitles:nil];
[alert show];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSDate *now = [NSDate date];
[datePicker setDate:now animated:NO];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.datePicker = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
AppDelegate.m
import "BiDAppDelegate.h"
#implementation BiDAppDelegate
#synthesize window = _window;
#synthesize rootController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
[[NSBundle mainBundle] loadNibNamed:#"TabBarController" owner:self options:nil];
[self.window addSubview:rootController.view];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
#end
You need to set the rootViewController to show the view controller you want (BiDDatePickerViewController) in the application:didFinishLaunchingWithOptions:
-(BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions (NSDictionary *) launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
[[NSBundle mainBundle] loadNibNamed:#"TabBarController" owner:self options:nil];
[self.window addSubview:rootController.view];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
BiDDatePickerViewController* viewController = [BiDDatePickerViewController new];
[self.window.rootViewController presentModalViewController:viewController animated:NO];
[viewController release];
return YES;
}
-(BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions (NSDictionary *) launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
BiDDatePickerViewController* viewController = [[BiDDatePickerViewController alloc]initWithNibName:#"TabBarController" bundle:nil];
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
[viewController release];
return YES;
}

PushViewController: Is this a memory leak?

I'm developing an iOS 4 with latest SDK and XCode 4.2 (I'm not using ARC).
I'm developing a Navigation Controller programmatically, and I have a question.
This is AppDelegate.h
#import <UIKit/UIKit.h>
#class ViewController;
#class SecondViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UINavigationController* navController;
ViewController* viewController;
SecondViewController* secondViewController;
}
#property (strong, nonatomic) UIWindow *window;
- (void) showSecondViewController;
#end
And this is AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
#import "SecondViewController.h"
#implementation AppDelegate
#synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
viewController.title = #"Menu";
navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBar.tintColor = [UIColor blackColor];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return YES;
}
- (void) dealloc
{
[_window release];
[viewController release];
[navController release];
[secondViewController release];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
...
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
...
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
...
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
...
}
- (void)applicationWillTerminate:(UIApplication *)application
{
...
}
- (void) showSecondViewController
{
secondViewController = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
secondViewController.title = #"Second";
[navController pushViewController:secondViewController animated:YES];
}
My question is about the last method, -(void)showSecondViewController;
May I add this line at the end?
[secondViewController release]
I've profiled the application, and I haven't see any memory leaks. But I have to ask it here, because I'm not sure.
You will get a memory leak if you call showSecondViewController method again.
You should release the secondViewController in your showSecondViewController method.
- (void) showSecondViewController
{
secondViewController = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
secondViewController.title = #"Second";
[navController pushViewController:secondViewController animated:YES];
[secondViewController release]
}
It will automatically be retained by navController when you do pushViewController:secondViewController

add a countdown, display the time and fire an action

Hi I am a beginner in programming
I have already created a tapping application, displaying the tap count after pressing the result button
I want to add a NSTimer, counting 30 second after the first tap (after the tap button was pressed for the first time).
at the same time, displaying the time count down on a label (UILabel timeLabel)
and after 30 second, the tap count will restart to 0.
Please kindly tell me if I need to post anything other than the following, Thanks!!
Here is my .h file
#import <UIKit/UIKit.h>
#import <AVFoundation/AVAudioPlayer.h>
#import <AudioToolbox/AudioToolbox.h>
#class Player;
#interface Tapping2ViewController : UIViewController
<AVAudioPlayerDelegate>
{
Player *aPlayer;
IBOutlet UILabel *timerLabel;
IBOutlet UILabel *resultLabel;
AVAudioPlayer *buttonPlayer;
NSTimer *lv1Timer;
NSInteger *counter1;
}
- (IBAction)addTap:(id)sender;
- (IBAction)getResult:(id)sender;
-(void)restartTapCount;
-(void)start;
#property (retain) NSTimer *lv1Timer;
#property (nonatomic, retain) IBOutlet UILabel *timerLabel;
#end
and my .M file
#import "Tapping2ViewController.h"
#import "Player.h"
#implementation Tapping2ViewController
#synthesize lv1Timer;
#synthesize timerLabel;
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil
bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)dealloc
{
[resultLabel release];
[lv1Timer release];
[aPlayer release];
[timerLabel release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
aPlayer = [[Player alloc] init];
[super viewDidLoad];
}
- (IBAction)addTap:(id)sender
{
//呢到係設定聲音, 首先要用NSSTRING 去 SET 左條路徑先
NSString *buttonFile = [[NSBundle mainBundle] pathForResource:#"button" ofType:#"wav"];
//之後再條NSSTRING 轉做NSURL (因為AVPLAYER 只認URL)
NSURL *buttonFileURL = [NSURL fileURLWithPath:buttonFile];
NSError *error = nil;
//設定AUDIO PLAYER 要播邊條 聲音 *記得SET DELEGATE 做自已去執行
buttonPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:buttonFileURL error:&error];
[buttonPlayer setDelegate:self];
NSLog(#"Before: %d", aPlayer.tapCount);
aPlayer.tapCount++;
//呼叫播放既METHOD
[buttonPlayer play];
NSLog(#"After: %d", aPlayer.tapCount);
/*
//即時顯示數字
aPlayer.result = aPlayer.tapCount;
NSString *sResult = [NSString stringWithFormat:#"%D", aPlayer.result];
resultLabel.text = sResult;
*/
}
- (IBAction)getResult:(id)sender {
aPlayer.result = aPlayer.tapCount;
NSString *aResult = [NSString stringWithFormat:#"%D", aPlayer.result];
resultLabel.text = aResult;
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
{
aPlayer.tapCount = 0;
resultLabel.text = #"0";
}
}
- (void)viewDidUnload
{
[resultLabel release];
resultLabel = nil;
[timerLabel release];
timerLabel = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
//下面係PART OF DETECT SHAKE 既METHOD
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
-(void)viewWillDisappear:(BOOL)animated
{
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
//去到呢到都係
#end
Here is how I do it in an app, on start :
count = COUNTDOWN_DURATION;
countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1
target:self selector:#selector(countDown)
userInfo:nil repeats:YES];
this will call a countDown method every second. Do whatever you want in that countDown method but make sure to stop the NSTimer on completion (and of course to decrement counter):
if (count < 0) {
[countdownTimer invalidate];
countdownTimer = nil;
}
...
count--;

UIView shows wrong orientation

Everything works ok on simulator , but on the real iphone 3g there is bug.
I call Splash Screen twice. First time - ok , second time i see the bug : http://img413.imageshack.us/i/bugicu.png/
How can i fix it ?
#interface iStateGameAppDelegate : NSObject
{
UIWindow* window;
UINavigationController* navigationController;
}
-(void) showSpalshScreen;
-(void) showSwitchViewController;
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
#end
#implementation iStateGameAppDelegate
#synthesize window;
#synthesize navigationController;
- (BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) launchOptions
{
[self showSpalshScreen];
[window makeKeyAndVisible];
return YES;
}
-(void) showSpalshScreen
{
SplashScreen* splashScreen = [[[SplashScreen alloc] initWithNibName:#"SplashScreen" bundle:[NSBundle mainBundle]] autorelease];
[window addSubview:[splashScreen view]];
}
-(void) showSwitchViewController
{
SplashScreen* splashScreen = [[[SplashScreen alloc] initWithNibName:#"SplashScreen" bundle:[NSBundle mainBundle]] autorelease];
[window addSubview:[splashScreen view]];
}
- (void) dealloc
{
[navigationController release];
[window release];
[super dealloc];
}
#interface SplashScreen : UIViewController {}
#end
#implementation SplashScreen
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
NSTimer *timer = [[NSTimer timerWithTimeInterval:1.0 target:self selector:#selector(timerFired:) userInfo:nil repeats:NO] retain];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (void)timerFired:(NSTimer *)timer
{
[[UIApplication sharedApplication] setStatusBarHidden:FALSE];
iStateGameAppDelegate* app = [UIApplication sharedApplication].delegate;
[app showSwitchViewController];
[[self view] removeFromSuperview];
[timer invalidate];
[timer release];
timer = nil;
}
- (void)dealloc {
[super dealloc];
}
Make sure the view's delegate is correctly set.
You should probably check for both UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationLandscapeLeft.