如何在iOS中将数据从容器发送到父视图控制器?

如何在iOS中将数据从容器发送到父视图控制器?,第1张

概述参见英文答案 > Passing Data between View Controllers                                    41个 我正在尝试将数据从容器(子视图)发送到父级.在另一个视图控制器中,我能够使用从父级向子级发送数据 -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sen 参见英文答案 > Passing Data between View Controllers41个
我正在尝试将数据从容器(子视图)发送到父级.在另一个视图控制器中,我能够使用从父级向子级发送数据
-(voID) prepareForSegue:(UIStoryboardSegue *)segue sender:(ID)sender

但是,我不确定如何将数据从子节点发送到父节点,特别是我正在尝试将属性userLat(它是容器的属性)发送给父节点.有什么建议?

PinVIEwController.m(父):

- (voID)vIEwDIDLoad{    [super vIEwDIDLoad];    // Do any additional setup after loading the vIEw.    NSLog(@"children : %@",self.childVIEwControllers);//this returns the child vIEw controller NSLog(@"children : %@",self.childVIEwControllers.userLat);//userLat is a property of the child vIEw controller,but displays an error in Xcode.}

MapWithinPinVIEwController(子,容器)

- (voID)vIEwDIDLoad{    GMSCameraposition *camera = [GMSCameraposition cameraWithLatitude:-33.86 longitude:151.20 zoom:6];    mapVIEw_ = [GMSMapVIEw mapWithFrame:CGRectZero camera:camera];    mapVIEw_.myLocationEnabled = YES;    mapVIEw_.delegate = self;    self.vIEw = mapVIEw_;} - (voID)mapVIEw:(GMSMapVIEw *)mapVIEw dIDTapAtCoordinate:(CLLocationCoordinate2D)coordinate {    NSLog(@"You tapped at %f,%f",coordinate.latitude,coordinate.longitude);    [mapVIEw_ clear];    GMSMarker *marker = [[GMSMarker alloc] init];    marker.position = CLLocationCoordinate2DMake(coordinate.latitude,coordinate.longitude);    self.userLat = @"test";    marker.map = mapVIEw_;}
解决方法 Apple建议您在prepareForSegue中将父级设置为子级的委托.然后,子进程可以使用委托方法(自定义协议)与父进行通信. 总结

以上是内存溢出为你收集整理的如何在iOS中将数据从容器发送到父视图控制器?全部内容,希望文章能够帮你解决如何在iOS中将数据从容器发送到父视图控制器?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1113878.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存