我在接收 geoPoint 对象的 block 内有这段代码:
UIViewController *mapViewController1 =
[[BSTGMapViewController alloc] initWithNibName"BSTGMapViewController_iPhone"
bundle:nil];
PFGeoPoint *currentLocation = geoPoint;
[self presentViewController:mapViewController1 animated:1 completion:nil];
如何将 geoPoint 变量传递给 mapViewController1,以便在
上使用它viewDidLoad 函数?我使用 XCode 4.6 定位 iOS 5。我该如何解决这个问题?
在 BSTGMapViewController 内部重载 initWithNibName 以传递参数
在 BSTGMapViewController 内部。
- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)nibBundleOrNil withGeoPointCLLocation*)userLocation;
并在 BSTGMapViewController.m 中实现
- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)nibBundleOrNil withGeoPointCLLocation*)userLocation
{
//usual code of init with nib name
locationhere=userlocation;
}
//你的代码
PFGeoPoint *currentLocation = geoPoint;
BSTGMapViewController *mapViewController1 =
[[BSTGMapViewController alloc] initWithNibName"BSTGMapViewController_iPhone"
bundle:nil withGeoPoint:currentLocation];
[self presentViewController:mapViewController1 animated:1 completion:nil];
关于iphone - 将变量传递给使用 presentViewController 加载的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15546058/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |