Problem setText UITextView
Posted
by Mat
on Stack Overflow
See other posts from Stack Overflow
or by Mat
Published on 2009-12-09T17:32:53Z
Indexed on
2010/03/11
20:04 UTC
Read the original article
Hit count: 491
Hi i have a problem. I have 2 viewcontroller, in the first there is a mapView that implements the function "calloutAccessoryControlTapped" to tap a button on an annotation on the mapView; in the second there is just a UITextView. I want to change the text of the UITextView (and show the SecondViewController) in the second controller once the button on annotation is clicked; here is my code
(FirstViewController)
Header
@interface FirstViewController<MKMapViewDelegate>{
IBOutlet MKMapView *mapView;
SecondViewController *secondV;}
@end
Implementation
@implementation FirstViewController
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
secondV = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
NSString *myS = @"some text here";
[secondV.myTextView setText:myS];
//Switch from this to the secondview [self presentModalViewController:secondV animated:YES]; @end
(SecondViewController)
Header
@interface SecondViewController{
IBOutlet UITextView *myTextView;
}
@property(nonatomic, retain)UITextView *postitTextView;
- (IBAction)backToMAp;
- (void)setText:(NSString *)string;
@end
Implementation
@implementation SecondViewController
- (IBAction)backToMAp{
//Back To First View; [self dismissModalViewControllerAnimated:YES];}
- (void)setText:(NSString *)string{
myTextView.text = string;}
In this code when i tap on the button ([self presentModalViewController:secondV animated:YES];) on annotation the first time the second view show up but the text of UITextView don't change, when i back on the FirstView ([self dismissModalViewControllerAnimated:YES];) and then again tap the button to switch again to secondView the text of UITextView change.....
Sorry for long thread and for my bad english!!
Thank you stack!
© Stack Overflow or respective owner