So I have 2 views. Let's call them View 1 and View 2.
View 1 has a UITextField named inputField and a button that opens a modal view, View 2. I also call [View 2 fillLabel], with fillLabel being a method declared in View 2.
View 2 has a label on it, named outputLabel, and a method to set it's label as mentioned above.
My View 1.m has an action assigned to it's button to display View 2 while at the same time calling [View 2 fillLabel].
However, it is not working. I have tried several different ways:
Basically, I am having trouble in -(void)fillLabel.
.... i even tried converting the text from the TextField into a string ... no luck.
Am I missing something? Do I have to make a whole class just to share a single line of text?
View 1 has a UITextField named inputField and a button that opens a modal view, View 2. I also call [View 2 fillLabel], with fillLabel being a method declared in View 2.
View 2 has a label on it, named outputLabel, and a method to set it's label as mentioned above.
My View 1.m has an action assigned to it's button to display View 2 while at the same time calling [View 2 fillLabel].
However, it is not working. I have tried several different ways:
Code:
======
View 1.h
======
#import <UIKit/UIKit.h>
#import "View2ViewController.h"
@class View2ViewController;
@interface View1ViewController : UIViewController {
IBOutlet View2ViewController *view2view;
IBOutlet UITextField *inputTextField;
}
@property(nonatomic, retain) IBOutlet View2ViewController *view2view;
@property(nonatomic, retain) IBOutlet UITextField *inputTextField;
-(IBAction)showModal:(id)sender;
-(IBAction)hideKeyboard:(id)sender;
@end
======
View 1.m
======
#import "View1ViewController.h"
@implementation View1ViewController
@synthesize inputTextField, view2view;
-(IBAction)showModal:(id)sender {
view2view.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:view2view animated:YES];
[view2view fillLabel];
}
Code:
======
View 2.h
======
#import <UIKit/UIKit.h>
#import "View1ViewController"
@class View1ViewController;
@interface View2ViewController : UIViewController {
IBOutlet UILabel *outputLabel;
View1ViewController *view1;
}
@property (nonatomic, retain) UILabel *outputLabel;
@property (nonatomic, retain) View1ViewController *view1;
-(IBAction)resignModal:(id)sender;
-(void)fillLabel;
@end
======
View 2.m
======
#import "View2ViewController.h"
#import "View1ViewController.h"
@implementation View2ViewController
@synthesize outputLabel, view1;
-(IBAction)resignModal:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
-(void)fillLabel {
label.text=view1.inputTextField.text;
}
Basically, I am having trouble in -(void)fillLabel.
.... i even tried converting the text from the TextField into a string ... no luck.
Am I missing something? Do I have to make a whole class just to share a single line of text?