以编程方式删除PageViewController

时间:2017-03-16 07:00:45

标签: ios objective-c uipageviewcontroller

我已按编程方式添加 Map<String, String> params = new HashMap<String, String>(); params.put("grant_type", "password"); params.put("username", email); params.put("password", password); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, AppConfig.URL_LOGIN, new JSONObject(params), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }){ @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/x-www-form-urlencoded"); return headers; } }; ,如下所示。有用。但是,当我尝试使用pageviewController删除时,它不会删除它。

添加pageViewController

[self.pageViewController.view removeFromSuperview];

删除pageViewController

self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];

1 个答案:

答案 0 :(得分:1)

使用以下说明删除pageViewController:

[self.pageViewController willMoveToParentViewController:nil];
[self.pageViewController.view removeFromSuperview];
[self.pageViewController removeFromParentViewController];