ios中滚动页面
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
int width=frame.size.width;
int height=frame.size.height;
scrollview=[[UIScrollView alloc] initWithFrame:CGRectMake(, , width, height)];
[self addSubview:scrollview];
for (int i=; i<; i++) {
UIImageView *imageview=[[UIImageView alloc] initWithFrame:CGRectMake(i*width, , width, height)];
imageview.image=[UIImage imageNamed:[NSString stringWithFormat:@"image%zi@2x.jpg",(i+)]];
[scrollview addSubview:imageview];
}
scrollview.contentSize=CGSizeMake(*width, height);
scrollview.pagingEnabled=YES;
scrollview.showsVerticalScrollIndicator=NO;
scrollview.showsHorizontalScrollIndicator=NO;
scrollview.delegate=self;
scrollview.bounces=NO; pagecontroller=[[UIPageControl alloc] initWithFrame:CGRectMake((width-)*0.5f, height--, , )];
[self addSubview:pagecontroller]; pagecontroller.currentPage=;
pagecontroller.numberOfPages=;
currentPage=; self.timer=[NSTimer scheduledTimerWithTimeInterval: target:self
selector:@selector(timer:) userInfo:nil repeats:YES];
[self.timer fire]; }
return self;
} -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
CGFloat width=self.bounds.size.width;
CGPoint point=scrollview.contentOffset;
CGFloat offenx=point.x;
pagecontroller.currentPage=offenx/width;
} -(void)timer:(NSTimer *)time{
if (currentPage>) {
currentPage=;
}
CGFloat width=self.bounds.size.width;
[UIView beginAnimations:nil context:nil];
scrollview.contentOffset=CGPointMake(currentPage*width, );
pagecontroller.currentPage=currentPage;
[UIView commitAnimations];
currentPage++;
}
ios中滚动页面的更多相关文章
- vue中滚动页面,改变样式&&导航栏滚动时,样式透明度修改
vue中滚动页面,改变样式&&导航栏滚动时,样式透明度修改.vue <div class="commonHeader" v-bind:class=" ...
- ios中iframe页面出现白屏问题
最近用ionic3开发的一个项目在ios中出现了白屏的问题 banner轮播图跳转网页 使用了iframe 但是却时不时的出现白屏现象 在android中一切正常 网上查资料发现 是因为ios不允许访 ...
- iOS 中 h5 页面 iframe 调用高度自扩展问题及解决
开发需求需要在 h5 中用 iframe 中调用一个其他公司开发的 html 页面. 简单的插入 <iframe /> 并设置宽高后,发现在 Android 手机浏览器上打开可以正常运行, ...
- [原]iOS中 Web 页面与 Native Code 的一种通信方式
在 iOS 开发中,Web 页面与 Native Code 通信可以分为两个方面: 1.Native Code 调用 Web 页面的方法:主要是调用页面中的 Javascript 函数. 2.Web ...
- iframe ios中h5页面 样式变大
实际项目开发中,iframe在移动设备中使用问题还是很大的,说一说我的那些iframe坑 做过的这个后台管理框架,最开始的需求是PC,但随着业务需要,需要将项目兼容到ipad,后台的框架也是使用的开源 ...
- ios中开始页面做法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...
- ios系统微信浏览器、safari浏览器中h5页面上拉下滑导致悬浮层脱离窗口的解决方法
一. 运行环境: iphone所有机型的qq浏览器,safari浏览器,微信内置浏览器(qq浏览器内核)等. 二. 异常现象: 1. 大幅度上下滑动h5页面,然后停止滑动,有时候会影响到页面滚动,如局 ...
- css 移动端页面,在ios中,margin-bottom 没有生效
在开发中,你会遇到各种美轮美奂的UI交互设计图,下面这种UI图,我在开发时就在布局上遇到一个小问题 问题现象:ios 手机滚动到底部,底部的margin-bottom不生效,Android手机和模拟器 ...
- 阻止iOS中页面弹性回滚,只允许div.phone_body的区块有弹性
使用说明:只要替换选择器:var selector = '.phone_body'; /** * 阻止iOS中页面弹性回滚,只允许div.scroller的区块有弹性 */ (function () ...
随机推荐
- C++中JSON的使用详解【转】
https://blog.csdn.net/admin_maxin/article/details/53175779 jsoncpp 主要包含三个class:Value.Reader.Writer.注 ...
- ORM数据库框架 greenDAO SQLite MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- PHP操作数据库函数比较
常用的php语法连接mysql如下 <?php $link = mysql_connect('localhost', 'user', 'password'); mysql_select_db(' ...
- C# 网络编程之webBrowser获取网页url和下载网页中图片
该文章主要是通过C#网络编程的webBrowser获取网页中的url并简单的尝试瞎子啊网页中的图片,主要是为以后网络开发的基础学习.其中主要的通过应用程序结合网页知识.正则表达式实现浏览.获取url. ...
- 【Java】Java-XML解析利器-SAX-高性能-易用
Java-XML解析利器-SAX-高性能-易用 java xml 大_百度搜索 (3)java处理比较大的xml文件 - SegmentFault How to read UTF-8 XML file ...
- 【Spark】SparkStreaming-流处理-规则动态更新-解决方案
SparkStreaming-流处理-规则动态更新-解决方案 image2017-10-27_11-10-53.png (1067×738) elasticsearch-head Elasticsea ...
- Python机器学习实践与Kaggle实战(转)
https://mlnote.wordpress.com/2015/12/16/python%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E5%AE%9E%E8%B7%B5 ...
- 谢宝友:会说话的Linux内核
我们本次开源专访的对象是一位认真钻研技术的工程师,谢宝友,他目前任职中兴通讯操作系统团队,他个人在业余时间前后共花费了6年时间完成了对Linux内核Linux 2.6.12内核源代码注释工作. 我们本 ...
- 【math】梯度下降法(梯度下降法,牛顿法,高斯牛顿法,Levenberg-Marquardt算法)
原文:http://blog.csdn.net/dsbatigol/article/details/12448627 何为梯度? 一般解释: f(x)在x0的梯度:就是f(x)变化最快的方向 举个例子 ...
- gl.h included before glew.h
So I'm trying to move my OpenGL code from Main() into a specific class that will handle the 3D gra ...