Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

ios - Thread1:exc_bad_access error - Programatic Modal View

I have been trying to get a Modal view to display with a transparant background - which I have managed programatically with the help of @Tommaso Resti Modal View Transparant background - stop lower layer hiding?

Prior to implementing the modal view programatically I had it connected via a segue - the modal (which has a class of shareScreenViewController) contains to buttons with ibconnections to methods in its .m file. The methods fired without issue with teh segue connection - but now the view is added programatically when i click on a button the app crashes with the error -

Thread1:Exc_Bad_Access(code=1...  

shown in the screenshot below - I have added breakpoints and it appears that the method isnt even called before the app crashes - No idea whats going on - can anyone offer any advice!?

enter image description here

UPDATE: from @Larme 's help below I enabled NSZombie and now get this error -

2013-11-15 15:04:37.754 GetPTFit[1574:60b] Animation completed 2013-11-15 15:04:39.419 GetPTFit[1574:60b] *** -[shareScreenViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x16e1f2d0 (lldb)

The code i'm using to setup the modal is as follows -

- (IBAction)shareBtn:(id)sender {


UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone"
                                                         bundle: nil];
UIViewController *myModalController = [mainStoryboard instantiateViewControllerWithIdentifier:@"shareScreenViewController"];
[myModalController.view setFrame: CGRectMake(0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
[self.view addSubview: myModalController.view]; /* UPDATED HERE! */


/* Animate it from the bottom */
[UIView animateWithDuration:.5 animations:^{
    CGAffineTransform move = CGAffineTransformMakeTranslation(0, -[UIScreen mainScreen].bounds.size.height);
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    myModalController.view.transform = move;   /* UPDATED HERE */
} completion:^(BOOL finished) {
    if(finished) {
        NSLog(@"Animation completed");
    }
}];

}

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...