Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
Hi all.

Trouble tracking down a bug. It since it doesn't occur on my iphone 4.

When the player wins a game I put up a UIAlert with a text field.

Code:
-(void)showWinAlert
{
    NSLog(@"gameTime was:%@",userScore.gameTime);
    
    NSMutableString *messageAlert = [[NSMutableString alloc]initWithFormat:
                                     @"with Time: %@",userScore.gameTime];
    // Testing alert //
    winAlert = [[UIAlertView alloc] initWithTitle:@"New High Score!!!" 
                                          message:messageAlert
                                         delegate:self
                                cancelButtonTitle:@"OK !"
                                otherButtonTitles:nil];
    
    // if High Score then //
    [winAlert setAlertViewStyle:UIAlertViewStylePlainTextInput];
    [winAlert textFieldAtIndex:0].keyboardAppearance = UIKeyboardAppearanceAlert;
    [winAlert  becomeFirstResponder];    
    [[winAlert textFieldAtIndex:0] setTextAlignment:UITextAlignmentCenter];
    [winAlert textFieldAtIndex:0].text=@"YourName";
    
    // hilight all the text in the field //
   
    // delegate the textfield in the Alert so we can limit size of input //
    UITextField *theTitleTextField = [winAlert textFieldAtIndex:0];
    theTitleTextField.delegate = winAlert.delegate;
    [myTable reloadData];
    [winAlert show];
        
}

but it crashes when the UIAlert is shown. The Alert overtop of a MOV?
Could that be what's causing the crash? That code follows.

Code:
-(void)playWinMovie
{
initWithFrame:CGRectMake(0,0,cgSize.width,cgSize.height)];
    NSString *url = [[NSBundle mainBundle] pathForResource:@"TheEnd_Music" ofType:@"mov"];
    player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
    player.controlStyle =  MPMovieControlStyleNone;
    player.scalingMode =  MPMovieScalingModeAspectFill;
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(movieFinnishedCallback:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:player];
    
       // set the size of the movie // 
    player.view.frame = CGRectMake(0, 0,CGRectGetWidth(screenBounds),
                                   CGRectGetHeight(screenBounds));
    
    [player.view setAlpha:0.2];
    [player.view setHidden:NO];
   
    [[self window] addSubview:player.view];
  
   
    [player play];
    [audioPlayer pause];
}

Any Ideas. As I said, it works perfectly on my iphone 4 with iOS 7, but I understand how it would Suk if you win and then it crashes where you enter your name... sigh...

thanks
Ian
 

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
not Simulator.

It's on her iphone 5 not the simulator. And Worst it doesn't occur all the time.
but often enough.

Basically it closes the app, and pops her to home screen.

thanks
Ian
 

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
Copy that next time she syncs her phone, I'll find and post them..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.