【问题标题】:Unable to pass variables from one view to another无法将变量从一个视图传递到另一个视图
【发布时间】:2010-04-18 19:07:42
【问题描述】:

我有一个包含三个 UIButton 的详细视图,每个 UIButton 都将不同的视图推送到堆栈上。其中一个按钮连接到 MKMapView。当按下该按钮时,我需要将纬度和经度变量从详细视图发送到地图视图。我正在尝试在 IBAction 中添加字符串声明:

- (IBAction)goToMapView {

MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil];

mapController.address = self.address;
mapController.Title = self.Title;
mapController.lat = self.lat;
mapController.lng = self.lng;

//Push the new view on the stack
[[self navigationController] pushViewController:mapController animated:YES];
[mapController release];
mapController = nil;

}

但是当我尝试构建时,我得到了这个:'错误:分配中不兼容的类型'对于 lat 和 lng 变量。所以我的问题是我是否要以正确的方式将变量从一个视图传递到另一个视图? MKMapView 接受纬度和经度作为字符串还是数字?

【问题讨论】:

    标签: iphone objective-c uibutton mkmapview


    【解决方案1】:

    您似乎做得很好,但正如编译器错误所说,您的变量具有不兼容的类型。确保self.latmapController.lat 具有相同的类型(lng 变量相同)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-27
      • 2022-11-22
      • 1970-01-01
      • 2017-05-20
      • 1970-01-01
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      相关资源
      最近更新 更多