Tell me pzhst what I did wrong ?? I want to press the button to display the image code on another controller !!! First: // ViewController.h

#import <UIKit/UIKit.h> #import "DetailViewController.h" @interface ViewController : UIViewController <UIImagePickerControllerDelegate> - (IBAction)buttonSurprise:(id)sender; 

// ViewController.m

 #import "ViewController.h" #import "DetailViewController.h" @interface ViewController () @property(strong, nonatomic) UIImage*picker; @property (strong, nonatomic) IBOutlet UIImageView *imageName; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (IBAction)buttonSurprise:(UIButton *)sender { self.picker = [UIImage imageNamed: @"vk-group-250x240.jpg"]; self.imageName.image= self.picker; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"segueOne"]) { DetailViewController *twoVC = (DetailViewController *)[segue destinationViewController]; twoVC.img = self.picker; }} @end 

Second: // DetailViewController.h

 #import <UIKit/UIKit.h> #import <MobileCoreServices/MobileCoreServices.h> @interface DetailViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> @property (weak, nonatomic) IBOutlet UIImageView *bigImage; @property (weak, nonatomic) IBOutlet UITextView *bigText; @property (strong, nonatomic) UIImage*img; 

// DetailViewController.m

 #import "DetailViewController.h" #import "ViewController.h" @interface DetailViewController () @end @implementation DetailViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.bigImage.image = self.img; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end 
  • 3
    To format a code, select it with the mouse and press the {} button. - Jofsey
  • Daouzh porridge came out !!

1 answer 1

1) Use search sometimes: https://ru.stackoverflow.com/questions/334220

2) Everything should work, a couple of lines then - breakpoint and see what and where you can not. Is the condition at least satisfied?

 if ([segue.identifier isEqualToString:@"segueOne"]) 
  • Thanks for the answer! I just did it by analogy, I’ve been programming for two weeks, I still don’t know how to check if the conditions are met or not. I’ll try to look in the tutorials too. - SergeyXcode
  • @SergeyXcode, and how you wrote it: if ([segue.identifier isEqualToString: @ "segueOne"]) {DetailViewController * twoVC = (DetailViewController *) [segue destinationViewController]; twoVC.img = self.picker; } - AlessandroDP
  • I understood everything about what they had in mind, it is being executed --- forcibly clicked brepppoind and everything turned out - thanks, it remains to learn how to breakpoints) - SergeyXcode
  • @SergeyXcode, well, nice)) - AlessandroDP