Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2010, 09:19 AM   #1 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default 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];
iSDK is offline   Reply With Quote
Old 09-11-2010, 06:41 PM   #2 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Do you have an orientationChanged: method? Note the colon on the end.

What does the crash message in the console say?
__________________

Free Games!
smasher is offline   Reply With Quote
Old 09-11-2010, 07:32 PM   #3 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

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 View Post
Do you have an orientationChanged: method? Note the colon on the end.

What does the crash message in the console say?
iSDK is offline   Reply With Quote
Old 09-11-2010, 07:52 PM   #4 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

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.
smasher is offline   Reply With Quote
Old 09-11-2010, 08:33 PM   #5 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

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 View Post
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.
iSDK is offline   Reply With Quote
Old 09-12-2010, 09:38 AM   #6 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

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!
smasher is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:57 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0