I am creating an application that behaves like the default Message.app on the iPhone, where the user composes a text message in a UITextField
and, by clicking the Submit button, the UITextField
in ComposeViewController
will be transferred to the UILabel
table UILabel
in the user cell in MasterViewController
, as well as in DetailViewController
, where another UILabel
will get a text value from a UITextField
. DetailViewController
is a ViewController
loaded when a user selects cells from UITableViewCells
.
I do read related articles below, but this does not work on my end.
- How to send text from a text field to another class?
- How to see text from one text box in another text box?
- How to send text field value to another class
Could you advise me how to implement this correctly? I know this easily. I just donβt know why it doesnβt work. ComposeVC is the ModalViewController
, and DetailVC is the view that loads when the user deletes a cell in the MasterVC table.
Thanks a lot!
Below is my code for ComposeVC.h:
UITextField *messageTextField; @property (nonatomic, retain) IBOutlet UITextField *messageTextField; - (IBAction)buttonPressed:(id)sender;
for ComposeVC.m
synthesize messageTextField; -(IBAction)buttonPressed:(id)sender { DetailVC *detailVC = [[DetailVC alloc] init]; detailVC.messageText = messageTextField.text; }
for DetailVC.h
NSString *messageText; @property (nonatomic, copy) NSString *messageText;
for DetailVC.m
@synthesize messageText; - (void)viewLoad { testLabel.text = messageText; }
testLabel is a UILabel inside my DetailVC.
source share