SCCustomerDetailVC.h(提交VC)
#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(提交VC)
- (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(Modal VC)
#import "SCCustomersVCDelegate.h"@class SCCustomerDetailVC;@interface SCCustomersVC : UIVIEwController <UItableVIEwDelegate,UItableVIEwDataSource,UISearchbarDelegate>@property (weak,nonatomic) ID <SCCustomersVCDelegate> delegate;@end
SCCustomersVC.m(Modal VC)
- (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解决方法 我想你差不多了编辑 – 刚刚学习了 here这个vIEwWillAppear的行为在iOS> 5中有所不同.您仍然希望视图将以您的模型状态更新您的视图,因为它需要在初始演示时执行此 *** 作.
从您的modal vc或委托方法中调用它也可以.所以添加代码来vIEwWillAppear更新视图与视图控制器的模型状态…
// SCCustomerDetailVC.m- (voID)vIEwWillAppear:(BOol)animated { [super vIEwWillAppear:animated]; // making up an IBOutlet called someLabel // making up a model method (description) that returns a string representing your model self.someLabel.text = [self.customer description];}
然后从显示的vc或委托中,调用vIEwVIEwWillAppear:
- (voID)passCustomer:(SCCustomer *)customer{ self.customer = customer; [self vIEwWillAppear:YES]; [self dismissVIEwControllerAnimated:YES completion:^{}];}总结
以上是内存溢出为你收集整理的ios – 在通过委托解除其呈现的模态视图控制器后,在UIViewController中刷新数据全部内容,希望文章能够帮你解决ios – 在通过委托解除其呈现的模态视图控制器后,在UIViewController中刷新数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)