Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411516 Posts in 69380 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 09:33:31 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)[SOLVED] UILabel applying CGAffineTransformMakeRotation causing mysterious crash
Pages: [1]
Print
Author Topic: [SOLVED] UILabel applying CGAffineTransformMakeRotation causing mysterious crash  (Read 2533 times)
X3N
Level 6
*


View Profile
« on: April 13, 2010, 07:58:06 PM »

Er, C icon because there's no Objective-C  Embarrassed

http://stackoverflow.com/questions/2634488/uilabel-applying-cgaffinetransformmakerotation-causing-mysterious-crash

Quote


In

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil parentController:(GameViewController *)myGameController{

Have a series of transforming labels like so:

    deg90 = 1.570796326794897;

//....transforms background.center = CGPointMake(160,230); background.transform = CGAffineTransformMakeRotation(deg90);

    BetLabel.text = @"test";      
    BetLabel.transform = CGAffineTransformMakeRotation(deg90);

That last line is crashing me with:

2010-04-13 21:04:47.858 Game[1204:207] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray objectAtIndex:]: index (1) beyond bounds (1)' 2010-04-13 21:04:47.893 Game[1204:207] Stack: ( 864992541, 859229716, (lots of numbers)

But if I comment it out, I get the text changing fine. Uh oh, just did a test.. turns out the other transforms were on UIImageViews. Apparently rotating a label in this xib is causing the crash.

But in another file the transforms are working fine:

    newprofileentry.transform = CGAffineTransformMakeRotation(1.570796326794897);
    playerb0.transform = CGAffineTransformMakeRotation(1.570796326794897);
    playerb1.transform = CGAffineTransformMakeRotation(1.570796326794897);

Tried substituting deg90 with the full float value, still the same crash.

Tried cleaning cache, restarting IB and Xcode, cleaning all targets. Program has been running fine until I just added these labels. Tried deleting the label, readding and reconnecting the Outlet, too.

Thanks for reading, hope someone has an idea about this.

Cheers!
objective-c interface-builder uilabel xcode iphone
edit|delete|flag
   
asked 1 hour ago

   
community wiki

quantumpotato
   
     [this is a great comment]
    [flag this comment as noise, offensive, or spam]
   
Your error message means that the error is somewhere in array's managing - there are an array with one element, and you are trying to use the second element (with index 1). That's why I think that you search an error in wrong place. Maybe, you have some arrays in your code? – kpower 53 mins ago
   
Thanks for the response. I do. I also have been adding the labels to the view as subviews - but why would .transform affect this? The labels aren't in any array except for the subview. Tried putting this code before I initialize the arrays, still crashing. Don't have any arrays with just 0 or 1 size.. seems to be a problem with the UILabel itself! – quantumpotato 1 min ago edit  [delete this comment]

Help is much appreciated  Noir
« Last Edit: April 29, 2010, 07:51:11 AM by X3N » Logged

destiny is truth pre-op
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #1 on: April 17, 2010, 10:52:06 AM »

Did you get this resolved?

And can you possibly post a bit more of the code? What's BetLabel for example?

I think your commenter on stack overflow has the right idea. I would not expect this code to work in the init method. The normal place to do this kind of initialization is awakeFromNib or viewWillAppear:(BOOL)animated. Did you try that?
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
X3N
Level 6
*


View Profile
« Reply #2 on: April 28, 2010, 07:30:53 AM »

Hey, got things working.. there were some other weird glitches, turned out problems with some array indexes earlier on.. that didn't show up until I did a clean build. Cheers Smiley
Logged

destiny is truth pre-op
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic