Reputation: 16157
I am an IOS noob and this may be a dumb question, so here it is. I have two views. View A and View B. View A has my textField (for my message) and View B has my send button. Is it possible to send text inputed in View A from my send button in View B? Or is there a better way to do this?
Basically what I am trying to do is share a message using a menu. After the user clicks the send message a popup will display asking the user how to send. (IE: Send as Email, Share on Twitter, Share on Facebook, or Cancel).
My FIRST VIEW
My SECOND VIEW
Also just so I am clear. I don't expect anyone to solve it just wondering if anyone has ever done something like this before. If you want to provide possible solution that would be awesome. But really, more or less, I am looking for some insight.
Upvotes: 1
Views: 5134
Reputation: 4761
It is easy if all your widgets (the textfield, the button and the action sheet) are all ivars of the same view controller.
So, in the same controller, the button will trigger the selectSendingMethod which will display the pop up and each button of this sheet will call an adequate method.
That should solve your problem.
Upvotes: 0
Reputation: 1064
Question: "Is it possible to send text inputed in View A from my send button in View B? Or is there a better way to do this?"
Answer: Yes, it is possible. Here is a tutorial which contains an explanation of how to send an email from an app: http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email/. In the toolbar in the first view you might consider using a standard system image, UIBarButtonSystemItemAction, instead of "Send Message." You might also consider using a UIActionSheet instead of the second view. Apple says, "Use the UIActionSheet class to present the user with a set of alternatives for how to proceed with a given task."
Upvotes: 2
Reputation: 1027
Yes this is possible through several methods. The most OO and IMO the best way will be to create a custom init
method on ViewB.
Something like -(id) initWithEmail(NSString* email, NSString* message)
Upvotes: 1