嗨,我有一个问题。我有2个viewcontroller,首先有一个mapView实现了“calloutAccessoryControlTapped”功能来点击mapView上的注释按钮; 在第二个里面只有一个UITextView。 一旦点击了注解上的按钮,我想更改第二个控制器中的UITextView的文本(并显示SecondViewController);这里是我的代码问题setText UITextView
(FirstViewController)
部首
@interface FirstViewController<MKMapViewDelegate>{
IBOutlet MKMapView *mapView;
SecondViewController *secondV;}
@end
实施
@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];
//交换机从此到secondview [自我presentModalViewController:secondV动画:YES]; @end
(SecondViewController)
部首
@interface SecondViewController{
IBOutlet UITextView *myTextView;
}
@property(nonatomic, retain)UITextView *postitTextView;
- (IBAction)backToMAp;
- (void)setText:(NSString *)string;
@end
实施
@implementation SecondViewController
- (IBAction)backToMAp{
//返回第一个视图; [自dismissModalViewControllerAnimated:YES];}
- (void)setText:(NSString *)string{
myTextView.text = string;}
在该代码时,我轻触按钮([自我presentModalViewController:secondV动画:YES];)上标注在第一时间的所述第二视图中显示,但该文本的UITextView不会改变,当我回到FirstView([self dismissModalViewControllerAnimated:YES];)然后再次点击按钮再次切换到secondView的UITextView文本更改.....
抱歉线程和我的英语不好!
谢谢你的堆栈!