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 () ...
随机推荐
- go语言之进阶篇error接口的使用
1.error接口的使用 示例: package main import "fmt" import "errors" func main() { //var e ...
- C++中JSON的使用详解【转】
https://blog.csdn.net/admin_maxin/article/details/53175779 jsoncpp 主要包含三个class:Value.Reader.Writer.注 ...
- [leetcode]Gray Code @ Python
原题地址:https://oj.leetcode.com/problems/gray-code/ 题意: The gray code is a binary numeral system where ...
- Unique Binary Search Trees leetcode java
题目: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For e ...
- 构建配置 defaultConfig signingConfigs buildTypes productFlavors dependencies
测试项目位置:https://github.com/baiqiantao/FragmentTest.git 项目结构: project 目录的 build.gradle 文件 // Top-level ...
- 原生javascript实现异步的7种方式
1.$(document).ready 点评: 需要引用jquery :兼容所有浏览器. 2.标签的async=”async”属性 async的定义和用法(是HTML5的属性) async 属性规定一 ...
- Nginx网站常见的跳转配置实例
相信大家在日常运维工作中如果你用到nginx作为前端反向代理服务器的话,你会对nginx的rewrite又爱又恨,爱它是因为你搞定了它,完成了开发人员的跳转需求后你会觉得很爽,觉得真的很强大,恨它是因 ...
- TF-IDF及其算法
TF-IDF及其算法 概念 TF-IDF(term frequency–inverse document frequency)是一种用于资讯检索与资讯探勘的常用加权技术.TF-IDF是一种统计方法,用 ...
- capwap学习笔记——初识capwap(三)
2.5.6 CAPWAP状态机详解 2.5.6.1 Start to Idle 这个状态变迁发生在设备初始化完成. ¢ WTP: 开启CAPWAP状态机. ¢ AC: 开启CAPWAP状 ...
- Xamarin/Mono IOS Limitations
http://developer.xamarin.com/guides/ios/advanced_topics/limitations/ Since applications on the iPhon ...