09-11-2010, 09:19 AM
#1 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
Orientation making simulator crash
Hi, i am trying to add notifications for the orientation being changed, but whenever i implement the code the iphone simulator quits.
Code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
09-11-2010, 06:41 PM
#2 (permalink )
Registered Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Do you have an orientationChanged: method? Note the colon on the end.
What does the crash message in the console say?
__________________
Free Games!
09-11-2010, 07:32 PM
#3 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
I think the method is
Code:
- (void)orientationChanged: (id) sender
{
//my code
}
The crash message is the standard sig fault (bad exec, etc)
Quote:
Originally Posted by
smasher
Do you have an orientationChanged: method? Note the colon on the end.
What does the crash message in the console say?
09-11-2010, 07:52 PM
#4 (permalink )
Registered Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
The crash message before the Stack: ( ... ) bit is probably helpful. Please post it.
If it's just a EXC_BAD_ACCESS then either your object that's getting the message was deallocated, or you're doing something bad inside your orientationChanged: method. Does that method even get run? Add a breakpoint or NSLog and find out.
__________________
Free Games!
Last edited by smasher; 09-11-2010 at 07:55 PM .
09-11-2010, 08:33 PM
#5 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) anOrientation
{
printf("Is Portrait?: %s\n",
UIDeviceOrientationIsPortrait(anOrientation)
? "Yes" : "No");
printf("Is Landscape?: %s\n",
UIDeviceOrientationIsLandscape(anOrientation)
? "Yes" : "No");
return YES;
}
- (NSString *) orientationString
{
switch ([[UIDevice currentDevice] orientation])
{
case UIDeviceOrientationUnknown: return @"Unknown";
case UIDeviceOrientationPortrait: return @"Portrait";
case UIDeviceOrientationPortraitUpsideDown: return @"Portrait Upside Down";
case UIDeviceOrientationLandscapeLeft: return @"Landscape Left";
case UIDeviceOrientationLandscapeRight: return @"Landscape Right";
case UIDeviceOrientationFaceUp: return @"Face Up";
case UIDeviceOrientationFaceDown: return @"Face Down";
default: break;
}
return nil;
}
- (void) orientationChanged: (id) sender
{
NSLog(@"Orientation changed to %@", [UIDevice currentDevice].orientationString);
self.log = [NSMutableString string];
[self doLog:[UIDevice currentDevice].orientationString];
}
Quote:
Originally Posted by
smasher
The crash message before the Stack: ( ... ) bit is probably helpful. Please post it.
If it's just a EXC_BAD_ACCESS then either your object that's getting the message was deallocated, or you're doing something bad inside your orientationChanged: method. Does that method even get run? Add a breakpoint or NSLog and find out.
09-12-2010, 09:38 AM
#6 (permalink )
Registered Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Code:
[self doLog:[UIDevice currentDevice].orientationString];
That line looks crashworthy. I don't think UIDevice has a "orientationString" property. You probably meant [self orientationString] there if you're trying to call your orientationString method. I assume doLog: is another method you wrote in this class.
__________________
Free Games!
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 341
11 members and 330 guests
bignoggins , carlandrews , cgokey , givensur , hzwegjxg , jenniead38 , linkmx , mraalex , PixelInteractive , Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38