嗨,我有一個問題。我有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文本更改.....
抱歉線程和我的英語不好!
謝謝你的堆棧!