Quote:
Originally Posted by JohnMabassa
Hi
I have an application with a two text fields in one view(view1) and two labels in another view ( view2). I have a button in view1, when it is pressed it loads view2 and I want to change the label to the text that i entered in the text field. How can I do it?........... i have read somewhere in the forum about delegates and all, I read in details but I was not able to figure out how to use it.
Can anyone provide me a sample code?
Thanks in Advance
-John
|
I think you are invoking the second view (view2) in the following manner.
.h file of view1
#import <UIKit/UIKit.h>
#import "View2Controller.h"
@interface View1Controller : UIViewController {
View2Controller *view2;
}
@property (nonatomic,retain) View2Controller * view2;
@end
in .m file of view2
if(self.view2 ==nil) {
View2Controller *view2Controller = [[View2Controller alloc] initWithNibName:@"View2View" bundle:[NSBundle mainBundle]];
self. view2 = view2Controller;
[view2Controller release];
[self.navigationController pushViewController:self. view2 animated:YES];
In view2, create a property by name textValue andyou can set the text field value to this property just before the the last line of code.
for eg:
view2.textvalue=myTextField.text;
[self.navigationController pushViewController:self. view2 animated:YES];