我是objective-c编码的新手。
我正在制作一个练习应用程序,我需要从一个带有NSURLSession的API获取一些json数据,并将日期发送到PageViewController。
所以目前我在方法'getWeer'中获取我的json数据,我在制作pageViewController之前调用它(在viewDidLoad中)。但是因为我认为NSURLSession运行异步并且不完整,所以当我尝试在我的pageViewController中访问它时,json数据总是为空。
如何在NSURLSession完成后创建pageViewController?
commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}”,
"--sourcemap-output", "source.map",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets dest", resourcesDir
答案 0 :(得分:0)
异步完成后调用此方法。
// Create page view controller
-(void)setupPageViewController {
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30);
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}