English 中文(简体)
Problem setText UITextView
原标题:

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!

最佳回答

I forget to set myTextView as @property:

@property(nonatomic, retain)UITextView *myTextView;

and i forget to insert the @syntesize in the implementation:

@syntesize myTextView;
问题回答

You have two UITextViews in your code: myTextView and postitTextView. In IB have you got the right one in the your UIView?





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签