UIAlert with Text is Crashing on Iphone 5 iOS7

Discussion in 'iOS Programming' started by IDMah, Feb 19, 2014.

  1. IDMah macrumors 6502

    IDMah

    Joined:
    May 13, 2011
    #1
    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
     
  2. larswik macrumors 68000

    Joined:
    Sep 8, 2006
  3. IDMah thread starter macrumors 6502

    IDMah

    Joined:
    May 13, 2011
    #3
    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
     
  4. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #4
    You can still get error messages from a device. We need to know more before we can help you.
     
  5. IDMah thread starter macrumors 6502

    IDMah

    Joined:
    May 13, 2011
    #5
    Copy that next time she syncs her phone, I'll find and post them..
     

Share This Page