How to remove the bottom gap of UIPageViewController

2024-04-06 03:48

本文主要是介绍How to remove the bottom gap of UIPageViewController,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

原文地址:http://stackoverflow.com/questions/19935887/how-to-remove-the-bottom-gap-of-uipageviewcontroller


7
down vote favorite
4

I am using UIPageViewController to show images full screen, the UIViewController which is added to UIPageController as a sub view / child has the images being showed using ImageView. Problem is the images arent comming fullscreen, instead the pagecontrol view's donts are appearing at the bottom and that space is completely wasted. Please check the image attached.

enter image description here

Here is the code

self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];self.pageController.dataSource = self;
[[self.pageController view] setFrame:[[self view] bounds]];NewsItemViewController *initialViewController = [self viewControllerAtIndex:0];NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];

Here NewsItemViewController is UIViewController showing images and some text and The MainViewController implements UIPageViewControllerDataSource protocol and necessary methods in MainViewController.

I believe there has to be a way to do show the things in full screen.

* Also the MainViewController is a part of a storyboard if that matters.


解决方法1://注:隐藏 UIViewPageController的字view(UIPageControl),然后调整view的大小。


28
down vote accepted

Finally got the solution myself I just hide the page control from UIViewPageController and then extended the size of the UIPageViewController to cover up the gap left due to absense of page control.

 NSArray *subviews = self.pageController.view.subviews;
UIPageControl *thisControl = nil;
for (int i=0; i<[subviews count]; i++) {if ([[subviews objectAtIndex:i] isKindOfClass:[UIPageControl class]]) {thisControl = (UIPageControl *)[subviews objectAtIndex:i];}
}thisControl.hidden = true;
self.pageController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height+40);
share improve this answer
解决方法2:

Curious. The docs say:

If both of the methods in “Supporting a Page Indicator” are implemented and the page view controller’s transition style is UIPageViewControllerTransitionStyleScroll, a page indicator is visible.

Those two methods are: //注:就是不重写下面这里两个方法

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
}- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { 
}

Are you implementing these two data source methods? If so, perhaps if you remove them you won't have to manually remove the page control (dots)? A quick test would be to change the

UIPageViewControllerTransitionStyleScroll

to

UIPageViewControllerTransitionStylePageCurl

and see if the page control indicator dots go away. (After commenting out your hide method, of course.)



这篇关于How to remove the bottom gap of UIPageViewController的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/878932

相关文章

27. Remove Elements

题目: 解答: 类似题26,注意下删除后的元素的移动方式即可 代码: class Solution {public:int removeElement(vector<int>& nums, int val) {if(nums.empty()) return 0;int len = nums.size();int lenafter = 0, head = 0;for(int i

BLE Profile(GATT与GAP)

一. 引言 现在低功耗蓝牙(BLE)连接都是建立在 GATT (Generic Attribute Profile) 协议之上,GATT 是一个在蓝牙连接之上的发送和接收很短的数据段的通用规范,这些很短的数据段被称为属性(Attribute)。 二. GAP 详细介绍GATT之前,需要了解GAP(Generic Access Profile),它在用来控制设备连接和广播。GAP使你的设备被其

[转载]python:remove方法的使用,remove、pop、del三者的区别

remove方法 描述 删除列表中的给定的对象 语法 list.remove() 参数 obj 参数(可选择性插入)obj的作用是要从列表中删除的对象的索引 使用如:list.remove(obj = list[0]) 返回值 remove方法删除后不会返回值 实例 list = [1, 2, 3, 4, 5]List1 = list.remove(1)print (li

Jquery empty() remove() detach() 方法的区别

引言: 最近项目中用到了这几个方法,感觉很大程度上有些相似,查了Jquery的api,同时也找了很多博客文章,发现还是理解不到区别。最后在很多材料和自己的事例验证中,终于找到了区别,不敢独占特拿出来分享。   方法简介:  empty() This method removes not only child (and other descendant)

关于蓝牙BLE的GAP/GATT

概述 蓝牙低功耗(BLE)是无线技术的一项关键创新,提供了能效和简化的连接。BLE功能的核心是通用访问配置文件(GAP,Generic Access Profile)和通用属性配置文件(GATT,Generic Attribute Profile),这对参与BLE技术的任何人来说都是必不可少的。 BLE起源于蓝牙特别兴趣组(SIG,Bluetooth Special Interest Grou

详解PyTorch中的`remove_self_loops`函数及其在图神经网络中的应用

remove_self_loops 引言什么是自环?`remove_self_loops`函数简介函数的基本用法为什么要移除自环?`remove_self_loops`的实际应用 引言 在图神经网络(GNN)的研究与应用中,数据预处理是实现高效和精确模型的关键步骤之一。remove_self_loops函数在这一过程中扮演了重要角色。本文将深入探讨这一函数的定义、作用以及在

Local GAP - Financial Statement Version 【海外BS\PL报表】

业务场景: 基于海外IFRS等会计准则为客户定义一套BS\PL报表 BS - 从科目余额抓取 PL - 从利润中心报表抓取 会计报表版本的建立: 路径:IMG>财务会计(新)>总账会计核算(新)主数据>总账科目>定义会计报表版本 事务代码:OB58 Chart of Account : Operation Chart of Account; Build up the

Prime Gap

Prime Gap 时间限制: 5 Sec  内存限制: 128 MB 题目描述 The sequence of n ? 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and

C#中List集合使用Remove方法详解——List使用Remove方法需要注意的坑?

目录 一、基本使用 1、简单类型的例子 2、复杂类型的例子 二、思考 三、深度解析 四、正确的使用方式 1、重写 Equals 和 GetHashCode 2、使用 LINQ 的 FirstOrDefault 方法 五、性能考虑 六、注意事项 总结         在C#中,List<T> 是一个常用的数据结构,它提供了一系列操作方法来管理其内部

remove_if详解

std::remove_if 函数是 C++ 标准库中的一个算法,它用于移除容器中满足特定条件的元素。然而,重要的是要理解 std::remove_if 的工作原理及其返回值,因为它并不真正地从容器中删除元素。 std::remove_if 接受三个参数: 指向容器中第一个元素的迭代器。指向容器中最后一个元素之后位置的迭代器(即尾后迭代器)。一个谓词(通常是一个函数或函数对象),该函数接受容器