0

I have application

I want a button to open another screen with done button

after click this button a data be transfered from the current screen to the previous one

like opening options screen , how to let the main view know the changes be done on this subview

Best regards

AMH
  • 6,363
  • 27
  • 84
  • 135

4 Answers4

1

You can use properties for this.

Create a property in the second class: .h file

@interface DetailViewController : UIViewController {

NSString *head;
}
@property(nonatomic,retain)NSString *head;

@end  

in .m file

@synthesize head;

Now in your firstviewcontroller or first class

if (dt==nil) {
    DetailViewController *d = [[DetailViewController alloc]initWithNibName:@"Detailview" bundle:nil];
    self.dt = d;
    [d release];
}

dt.head=itemsum;

[self.navigationController pushViewController:self.dt animated:YES];
Aman Aggarwal
  • 3,754
  • 1
  • 19
  • 26
0

Suppose you have to pass NSString to other class then declare one Nsstring in second class and make accessor method for nsstring and then call this code from first view controller

yournextviewcontroller *viewcontroller = [[yournextviewcontroller alloc] initWithNibName:@"yournextviewcontroller" bundle:nil];
            viewcontroller.Stringname = name;

[self.navigationController viewcontroller:evernotebook animated:YES];
iProgrammer
  • 3,099
  • 3
  • 33
  • 59
0

You can take UIView as IBOutlet in the same ViewController. Show that view with click on Button like

 IBOutlet UIView *yourAnotherScreenView; //Bind this to your view in XIB file.

 [self.view addSubView:yourAnotherScreenView];
 [self.view bringSubViewtoFront:yourAnotherScreenView];

Take Done button on the view and wireup the action event in the same controller and do the necessary stuff as required.

Janak Nirmal
  • 22,706
  • 18
  • 63
  • 99
0

Use the simple delegate concept of Objective-C .

Check very simple answers in the below post for using delegate in Objective-C .

How do I set up a simple delegate to communicate between two view controllers?

Community
  • 1
  • 1
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76