0
votes

I've recently created a app with Xcode. When 2 images collide, it sends me to a new screen (which is good). However, when i push the button to return me back to the original view, it goes blank. Can you tell me why? Any feed back is appreciated.

Here is code from the First .h file:

import

@interface ViewController : UIViewController {

IBOutlet UIImageView *image1;
IBOutlet UIImageView *image2;

}

@property (nonatomic, retain) UIImageView *image1; @property (nonatomic, retain) UIImageView *image2;

-(void)collision;

@end

And from the .m:

import "ViewController.h"

import "newview.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize image1, image2;

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *mytouch = [[event allTouches] anyObject];
image1.center = [mytouch locationInView:self.view];

[self collision];

}

-(void)collision {

if (CGRectIntersectsRect(image1.frame, image2.frame)) {
    newview *second = [[newview alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:second animated:YES];


}

}

here is code from the second .h (The one with the go back button):

  • (IBAction)retry:(id)sender;

and from the .m:

import "newview.h"

import "ViewController.h"

@interface newview ()

@end

@implementation newview

  • (IBAction)retry:(id)sender {

    ViewController *second = [[ViewController alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:second animated:YES];

}

1

1 Answers

0
votes

The blank screen is another modal view from (IBAction)retry:(id)sender.

You should use [self dismissModalViewControllerAnimated:YES]; in (IBAction)retry:(id)sender for going back to previous screen instead of presenting another modal view.