سؤال

مرحبا! عندي مشكلة. لدي 2 ViewController، في الأول، يوجد خريطة ميخفية تنفذ وظيفة "calloutaccessorycontroltappo" للنقر على زر في التعليق التوضيحي في MAPView؛ في الثانية هناك مجرد uitextview. أريد تغيير نص UITEXTVIEW (وإظهار The SecondViewController) في وحدة التحكم الثانية بمجرد النقر فوق الزر عند التوضيحية؛ هنا هو رمز بلدي

(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];

// التبديل من هذا إلى الدفع الثاني [pelf presentmodalviewcontroller: secondv الرسوم المتحركة: نعم]؛ @نهاية

(secondviewcontroller)

رأس

@interface SecondViewController{ 
IBOutlet UITextView *myTextView;
}

@property(nonatomic, retain)UITextView *postitTextView;
- (IBAction)backToMAp;
- (void)setText:(NSString *)string;
@end

تطبيق

@implementation SecondViewController

- (IBAction)backToMAp{

// العودة إلى العرض الأول؛ [الفصل الذاتي ModalViewControllerolated: نعم]؛}

- (void)setText:(NSString *)string{ 
myTextView.text = string;}

في هذا الرمز عند النقر فوق الزر ([[Self PrideModalViewController: SecondV Animated: نعم]؛) عند التعليق التوضيحي في المرة الأولى التي تظهر فيها العرض الثاني ولكن نص UITEXTVIEW لا يتغير، عندما أعود إلى المرحلة الأولى (الذاتي dillemodalviewcontrollerollerolated: نعم]؛) ثم انقر مرة أخرى اضغط على الزر للتبديل مرة أخرى إلى SecondView نص تغيير UITEXTVIEW .....

آسف لخيط طويل وللغة الإنجليزية سيئة!

شكرا لك كومة!

هل كانت مفيدة؟

المحلول 2

نسيت ضبط myTextView كما @property:

@property(nonatomic, retain)UITextView *myTextView;

وأنا نسيت إدراج @syntesize في التنفيذ:

@syntesize myTextView;

نصائح أخرى

لديك اثنين من uitextviews في الرمز الخاص بك: myTextView و postittitextview. في IB هل حصلت على الحق في Uiview الخاص بك؟

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top