के माध्यम से प्रस्तुत प्रस्तुत मोडल व्यू कंट्रोलर को खारिज करने के बाद UIViewController में ताज़ा डेटा मेरे पास काम करने वाला प्रतिनिधि है क्योंकि डेटा को मोडल से प्रस्तुत करने वाले व्यू कंट्रोलर में पास किया जा रहा है। लेकिन प्रस्तुत करने वाला दृश्य नियंत्रक मोडल से प्राप्त डेटा नहीं दिखा रहा है। मैंने अन्य पदों पर ध्यान दिया और वे प्रतिनिधि/प्रोटोकॉल विधि का उपयोग करने के लिए कहते हैं, लेकिन यह समझाएं कि प्रस्तुत करने वाले वीसी रीफ्रेश कैसे/क्यों। मुझे लगता है कि मेरा प्रतिनिधि गलत तरीके से सेटअप है। अन्यथा, डेटा रीफ्रेश करने का तरीका क्या है? मैंने जांच की है और viewWillAppear और viewDidAppear को कॉल नहीं किया जाता है।प्रतिनिधि
SCCustomerDetailVC.h (पेश कुलपति)
#import "SCCustomersVC.h"
@interface SCCustomerDetailVC : UIViewController <SCCustomersVCDelegate>
@property (atomic, strong) SCCustomer *customer;
@property (strong, nonatomic) IBOutlet UIButton *changeCustomerButton;
- (IBAction)changeCustomerButtonPress:(UIButton *)sender;
@end
SCCustomerDetailVC.m (पेश कुलपति)
- (IBAction)changeCustomerButtonPress:(UIButton *)sender
{
UINavigationController *customersNC = [self.storyboard instantiateViewControllerWithIdentifier:@"customersNC"];
SCCustomersVC *customersVC = (SCCustomersVC *)customersNC.topViewController;
customersVC.delegate = self;
[self presentViewController:customersNC animated:YES completion:nil];
}
//Protocol methods
- (void)passCustomer:(SCCustomer *)customer
{
self.customer = customer;
//At this point, self.customer has the correct reference
[self dismissViewControllerAnimated:YES completion:nil];
}
SCCustomersVC.h (मॉडल कुलपति)
#import "SCCustomersVCDelegate.h"
@class SCCustomerDetailVC;
@interface SCCustomersVC : UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate>
@property (weak, nonatomic) id <SCCustomersVCDelegate> delegate;
@end
SCCustomersVC.m (मॉडल वीसी)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SCCustomer *customer = [self customerAtIndexPath:indexPath];
[self.delegate passCustomer:customer];
}
SCCustomersVCDelegate.h
@class SCCustomer;
@protocol SCCustomersVCDelegate <NSObject>
@optional
- (void)passCustomer:(SCCustomer *)customer;
@end
आप प्राप्त करने के बाद क्या किया आपके प्रतिनिधि में सही संदर्भ। – Zen
@ जेन यूप, मैं इसके लिए आप सभी को परेशान करने के लिए खेद है। किसी कारण से, मैंने सोचा कि यह मेरी थका हुआ राज्य में अपनी आखिरी रात को "जादूगर" अपडेट करेगा। मुझे इसे अपडेट करने के लिए कोड जोड़ना होगा। – guptron