先用xcode5.1.1或更低版本创建一个Category,如图:

然后拷贝以下代码到刚创建的UIImageView+ForScrollView.m文件中:

- (void) setAlpha:(float)alpha {

    if (self.superview.tag == noDisableVerticalScrollTag) {
if (alpha == && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
if (self.frame.size.width < && self.frame.size.height > self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.height < sc.contentSize.height) {
return;
}
}
}
} if (self.superview.tag == noDisableHorizontalScrollTag) {
if (alpha == && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
if (self.frame.size.height < && self.frame.size.height < self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.width < sc.contentSize.width) {
return;
}
}
}
} [super setAlpha:alpha];
}

在.pch中定义这两个值:

#define noDisableVerticalScrollTag 836913
#define noDisableHorizontalScrollTag 836914

然后在你所用到UIScrollView、UITableView的视图控制器中:

#import "UIImageView+ForScrollView.h"

设置UIScrollView、UITableView:

    UIScrollView *scrollview = [[UIScrollView alloc]initWithFrame:self.view.bounds];
scrollview.contentSize = CGSizeMake(, );
scrollview.tag = noDisableVerticalScrollTag;
[scrollview flashScrollIndicators];
[self.view addSubview:scrollview]; //---
_tableView = [[UITableView alloc]initWithFrame:CGRectMake(, , , )];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsHorizontalScrollIndicator = YES;
_tableView.tag = noDisableVerticalScrollTag;
[_tableView flashScrollIndicators];
[self.view addSubview:_tableView];

如此即可让UIScrollView、UITableView的滚动条一直显示。

												

让UIScrollView、UITableView的滚动条一直显示的更多相关文章

  1. UIScrollView/UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)

    在 IOS 中,对 UIScrollView 的滚动条(ScrollBar Indicators)的自定义设置接口,一直都是很少的.除了能自定义简单的样式(UIScrollViewIndicatorS ...

  2. DuiLib 中滚动条不显示的问题

    DuiLib 很好用,同时在没有完全理解源码的前提下,坑也不少,比如今天遇到的添加滚动条不显示... 情况是这样的,将一个页面作为Tab控件的其中一页,为了代码不窝在一起,就没有在CreateCont ...

  3. 测试SDWebImage淡入淡出效果在UITableView中的重用显示问题

    测试SDWebImage淡入淡出效果在UITableView中的重用显示问题 这个是在上一篇教程的基础上所添加的测试环节! 效果图(从效果图中看是没有任何重用问题的): 源码: ImageCell.h ...

  4. overflow:scroll 滚动条不显示

    overflow:scroll 滚动条不显示 ::-webkit-scrollbar-thumb 可能因为 自定义的滚动条height比元素可展示内容大

  5. WPF的项目,ListBox 纵向滚动条不显示

    最近在做WPF的项目,ListBox 纵向滚动条不显示,但是鼠标滚轮可以在ListBox中使用,但是必须要出现纵向滚动条.  索性就直接在listBox外面包裹一个ScrollViewer. Scro ...

  6. css设置滚动条并显示或隐藏

    看效果,没有滚动条,超出div,开发中肯定不行. 有滚动条 最后就是想隐藏滚动条 代码 有滚动条并显示 <!DOCTYPE html> <html lang="en&quo ...

  7. 2018-11-30-WPF-解决-ListView-的滚动条不显示

    title author date CreateTime categories WPF 解决 ListView 的滚动条不显示 lindexi 2018-11-30 19:24:57 +0800 20 ...

  8. 11种常用css样式学习大结局滚动条与显示隐藏

    滚动条展示 overflow-x: hidden;/*是否对内容的左/右边缘进行裁剪*/overflow-y: hidden;/*是否对内容的上/下边缘进行裁剪*/overflow:scroll;/* ...

  9. UITableView中复用cell显示信息错乱

    UITableView继承自UIScrollview,是苹果为我们封装好的一个基于scroll的控件.上面主要是一个个的 UITableViewCell,可以让UITableViewCell响应一些点 ...

随机推荐

  1. xmlBean学习一

    在文档中看到了xmlBean的出现,因为项目使用JMS,模块之间通过xml文件传递数据,就学一下xmlBean,java中还提供了DOM,SAX来解析xm,但也是比较麻烦的:而xmlbean则将xml ...

  2. C++的优秀特性1:引用

    (转载请注明原创于潘多拉盒子) 一本典型的C语言教科书的厚度大约是200页左右,而一本典型的C++教科书的厚度至少要500页.比如K&R的<The C Programming Langu ...

  3. php safe mode bypass all <转>

    PHP safe mode bypass from 4.x to 5.x all. Functions: * mb_send_mail* curl_init* imap_open* mail* ion ...

  4. EXchange2010配置

    DAG配置: 组织配置:如果见证服务器是DC不是exchange服务器,那么需要在AD用户和计算机里面,将exchange trusted subsystem 添加到 DC的本地管理员组(/built ...

  5. Educational Codeforces Round 4 B. HDD is Outdated Technology 暴力

    B. HDD is Outdated Technology 题目连接: http://www.codeforces.com/contest/612/problem/B Description HDD ...

  6. Codeforces Round #311 (Div. 2) D. Vitaly and Cycle 图论

    D. Vitaly and Cycle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/p ...

  7. or1200下raw-os学习(任务篇)

    这次就来说说基于上一节介绍的系统框图去建立我们所需要的任务,顺便学习Raw-OS提供的API,根据上节的分析,对于Slave Board有如下设计: Slave Board有三个任务,分别负责测试阻抗 ...

  8. Yeoman+Express+Angular在Linux上开发配置方法

    $mkdir ExpressWithAngularTest $cd ExpressWithAngularTest choose needed components you'd like to add ...

  9. [AngularJS+ GSAP] Greensock TimelineLite Animation Sequences

    TimelineLite is a piece of the Greensock TweenMax library that provides the ability to create sequen ...

  10. Java Swing 探索(一)LayoutManager

    BorderLayout FlowLayout GridLayout GridBagLayout CardLayout BoxLayout 1.BorderLayout java.lang.Objec ...