在做一个功能的时候,遇到了这个问题。这里记录一下。
可滚动视图:UIScrollView,UITableView(是UIScrollView的子类)。
如果有的童鞋还是不理解,这个滚动视图,那么引一句网上的说法:
就像两张重叠在一起的纸,上面的纸中间有个320*480的屏幕状的洞,然后下面的纸可以无限大,显示是内容,你可以将手指通过这张洞来移动下面的纸,来阅读上面的信息。
而contentSize、contentInset和contentOffset 是 scrollView三个基本的属性。
contentSize: The size of the content view. 其实就是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。
contentOffset:The point at which the origin of the content view is offset from the origin of the scroll view. 是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
contentInset:The distance that the content view is inset from the enclosing scroll view.是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
另外UITableView是UIScrollView的子类,它们在上述属性又有所不同,tabelview的contentsize是由它的下列方法共同实现的
- (NSInteger)numberOfSections;
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
它会自动计算所有的高度和来做为它的contentsize的height.
分享到:
相关推荐
当view controller的automaticallyAdjustsScrollViewInsets值为YES时,viewController根据当前view中statusBar,navigaionTionBar,toolBar或者toolBar来自动调整scrollView的的contentInset和ContentOffset。...
UIScrollView的ContentSize 、ContentOffSet、ContentInset做的垂直滚动效果
NHHeaderFloatPro ScrollView Section Header 悬停 (For iOS) 1、本demo主要实现上拉悬停,即向上滚动TableView的时候...主要方法是控制TableView的contentInset和contentOffset及委托方法ScrollViewDidScroll:方法
分析通过使用调试器查看设置滚动视图的contentOffset ( 设置断点),似乎此问题是由滚动视图的手势处理引起的。 #0 0x0000000100dd8466 in ScrollViewChangeInsetJitter.ViewController.TracingScrollView.
ZHAutoLinesLabel 是 UILabel 的子类,支持 contentInset 和自动多行 为什么我创建这个标签 对于自动首选MaxLayoutWidth 我喜欢自动布局,对于标签,我这样做: self.setContentCompressionResistancePriority...
UIScrollView-中心该项目说明了使用contentInset在UISCrollView contentInset内容UISCrollView方法。 可以在上找到有关该项目的葡萄牙语 。
_searchcontroller.searchBar.frame = CGRectMake(self.searchcontroller.searchBar.frame.origin.x, self.searchcontroller.searchBar.frame.origin.y, self.searchcontroller.searchBar.frame.size.width, 44.0);...
图片框:顶部,ContentModel设置为AspectFill 内容列表:和根视图一样大 2、设置内容列表的contentInset,top为图片框的高度;backgroundColor为clearColor,这样图片框就显示出来了 3、滚动内容列表,实现...
ICTextViews 伊万诺·比伦奇( )... 在iOS 7以上版本中用于contentInset和textContainerInset方法。 包含许多已知的iOS 7+ UITextView错误的解决方法。兼容性支持的iOS版本: 4.x及更高版本(从iOS 5.x开始突出显示
1、创建头部的视图和tableview,需要注意的是tableview要设置contentInset,contentInsent 的顶部要和头部视图的背景图的高度一样,否则会有空隙(或是有遮挡)。 myTableView.contentInset = UIEdgeInsetsMake...
WSTagsField一个iOS文本字段,代表不同的标签。 用法let tagsField = WSTagsField()tagsField....5.0 tagsField.spaceBetweenTags = 10.0 tagsField.font = .systemFont(ofSize:12.0)tagsField.backgroundColo
随着iOS7导航条的半透明化,translucent属性的改变会影响tableView的ContentInset导致很多的下拉刷新第三方包出现问题 这是一个简单的下拉刷新和加载更多TableView 调用简单,数据处理可支持block和delegate(后续支持)...
MJRefresh兼容ios11demo,demo还是mj的代码,改了少量代码以适配新版内容。不修改ios11系统中contentInset含义,不修改系统变量赋值
Scrolling to the caret position now considers contentInset. UITextView completely ignored this. Typing will also consider contentInset and will update the scroll position accordingly. Pasted text will...
_topScrollview.contentInset = UIEdgeInsetsMake(0, 0, 0, IFScreenFit2s(45.f)); _topScrollview.scrollsToTop = NO; [self.view addSubview:_topScrollview]; _topScrollview.model = [ScrollviewModel ...
升级后,发现某个拥有tableView的界面错乱,组间距和contentInset错乱,因为iOS11中 UIViewController 的 automaticallyAdjustsScrollViewInsets 属性被废弃了,因此当tableView超出安全区域时,系统自动会调整...
动画,可自定义和灵活的即按即用框架,可更快,更轻松地进行iOS开发。 · · 状态 屏幕截图 KafkaRefreshStyle 热门截图 底部截图 本机 复制器伍迪 复制者艾伦 复制子圈 复制点 复制器弧 ReplicatorTriangle...
在你的视图控制器中,简单地调用insetsForView:方法和你想要获取 insets 的视图。 建议在viewWillLayoutSubviews:方法中执行此操作。 // 'self' is a UIViewController const UIEdgeInsets insets = [self ...
LDPageViewController LDPageContainerViewController,模仿UIPageViewController实现的容器视图控制器1)支持子视图Controller生命周期的初始化和明确性2)支持在手势触发的滑动过程中代码非动画定位的其他页面3)...
Features 支持链式编程配置,程序员的最爱 支持两种刷新结果提示 支持QQ和Common两种下拉刷新样式 支持contentInset 支持Cocoapods 支持MJRefresh到TGRefresh风格切换,只需要把mj_header改为tg_header,...