//
// LoopView.h
// Test_LoopScrollView
//
// Created by lanouhn on 14-8-30.
// Copyright (c) 2014年 vaercly@163.com 陈聪雷. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LoopView : UIView
@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIPageControl *pageControl;
@end
//
// LoopView.m
// Test_LoopScrollView
//
// Created by lanouhn on 14-8-30.
// Copyright (c) 2014年 vaercly@163.com 陈聪雷. All rights reserved.
//
#import "LoopView.h"
@implementation LoopView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setupScrollView];
[self setupPageControl];
}
return self;
}
- (void)setupScrollView
{
self.scrollView = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_scrollView.tag = 200;
_scrollView.contentSize = CGSizeMake(320 * 7, [UIScreen mainScreen].bounds.size.height);
// [_scrollView scrollRectToVisible:CGRectMake(320,0,320,[UIScreen mainScreen].bounds.size.height) animated:NO];
[_scrollView setContentOffset:CGPointMake(320, 0) animated:NO];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.pagingEnabled = YES;
[self addSubview:_scrollView];
[_scrollView release];
for (int i = 0; i < 7; i++) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(320 * i, 0, 320, [UIScreen mainScreen].bounds.size.height)];
if (i == 0) {
imageView.image = [UIImage imageNamed:@"girl_5.jpg"];
} else if (i == 6) {
imageView.image = [UIImage imageNamed:@"girl_1.jpg"];
} else {
imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"girl_%d", i]ofType:@"jpg"]];
}
[_scrollView addSubview:imageView];
[imageView release];
}
}
- (void)setupPageControl
{
self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(10, [UIScreen mainScreen].bounds.size.height - 40, 300, 20)];
_pageControl.tag = 100;
_pageControl.numberOfPages = 5;
_pageControl.currentPage = 0;
_pageControl.pageIndicatorTintColor = [UIColor grayColor];
_pageControl.currentPageIndicatorTintColor = [UIColor orangeColor];
[self addSubview:_pageControl];
[_pageControl release];
}
- (void)dealloc
{
self.scrollView = nil;
self.pageControl = nil;
[super dealloc];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
//
// RootViewController.m
// Test_LoopScrollView
//
// Created by lanouhn on 14-8-30.
// Copyright (c) 2014年 vaercly@163.com 陈聪雷. All rights reserved.
//
#import "RootViewController.h"
#import "LoopView.h"
@interface RootViewController ()<UIScrollViewDelegate>
{
BOOL _isOrder;
}
@end
@implementation RootViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
_isOrder = YES;
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changePage) userInfo:nil repeats:YES];
}
return self;
}
- (void)loadView
{
LoopView *loopView = [[LoopView alloc] initWithFrame:[UIScreen mainScreen].bounds];
loopView.backgroundColor = [UIColor grayColor];
self.view = loopView;
[loopView release];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
LoopView *loopView = ( LoopView *)self.view;
loopView.scrollView.delegate = self;
[loopView.pageControl addTarget:self action:@selector(handlePageControl:) forControlEvents:UIControlEventValueChanged];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
UIPageControl *pageControl = (UIPageControl *)[self.view viewWithTag:100];
int currentPage = scrollView.contentOffset.x / 320;
if (currentPage == 0) {
// [scrollView scrollRectToVisible:CGRectMake(320 * 5, 0, 320, [UIScreen mainScreen].bounds.size.height) animated:NO];
[scrollView setContentOffset:CGPointMake(320 * 5, 0) animated:NO];
pageControl.currentPage = 4;
} else if (currentPage == 6) {
// [scrollView scrollRectToVisible:CGRectMake(320, 0, 320, [UIScreen mainScreen].bounds.size.height) animated:NO];
[scrollView setContentOffset:CGPointMake(320, 0) animated:NO];
pageControl.currentPage = 0;
} else {
pageControl.currentPage = currentPage - 1;
}
}
- (void)handlePageControl:(UIPageControl *)pageControl
{
NSLog(@"%d", pageControl.currentPage);
UIScrollView *scrollView = (UIScrollView *)[self.view viewWithTag:200];
// [scrollView scrollRectToVisible:CGRectMake(320 * (pageControl.currentPage + 1),0,320,[UIScreen mainScreen].bounds.size.height) animated:NO];
[scrollView setContentOffset:CGPointMake(320 * (pageControl.currentPage + 1), 0) animated:YES];
}
- (void)changePage
{
//单序版
/*
LoopView *loopView = ( LoopView *)self.view;
int page = loopView.pageControl.currentPage;
page++;
page = page > 4 ? 0 : page;
loopView.pageControl.currentPage = page;
// [loopView.scrollView scrollRectToVisible:CGRectMake(320 * (page + 1), 0, 320, [UIScreen mainScreen].bounds.size.height) animated:NO];
if (page) {
[loopView.scrollView setContentOffset:CGPointMake(320 * (page + 1), 0) animated:YES];
} else {
[loopView.scrollView setContentOffset:CGPointMake(320 * (page + 1), 0) animated:NO];
}
*/
//双序版
LoopView *loopView = ( LoopView *)self.view;
int page = loopView.pageControl.currentPage;
if (_isOrder) {
page++;
page = page > 4 ? 0 : page;
if (!page) {
_isOrder = NO;
page = 3;
}
} else {
page--;
page = page < 0 ? 0 : page;
if (!page) {
_isOrder = YES;
page = 0;
}
}
loopView.pageControl.currentPage = page;
[loopView.scrollView setContentOffset:CGPointMake(320 * (page + 1), 0) animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
相关推荐
UIScroll View无限循环的超级简单的实现
UIScrollView创建后必须要被添加到其他的视图控制器或者view中。初始化UIScrollView后必须设置contentSize属性,这个属性的值决定了可以滚动的具体的size。因为我们使用UiscrollView是为了展示超过某一区域的内容,所以我们在设置contentSize的值时,必须大于等于其初始化时的frame的值。 UIScrollView可以看做是由一个窗口和一个背景板组成,窗口是我们可以看到的区域,就想我们坐火车时看到的那样,当窗口外面的风景在移...
鸿蒙开发中ScrollView用法的一个坑
然后就是由于ScrollView的直接子视图DirectionLayout的height为match_parent,那么tv_many_words和tv_many_words内容是无法上下滑动的(ps:这两个的内容设置了很长的字符串)。但是,如果DirectionLayout的height为match_content,那么其内部的两个文字控件内容是可以滑动的。这点和Android的用法貌似不一样。如上图所示,这样的界面中,底部的文字控件是显示不出来的。这点和Android用法一样。
NGUI UIScrollView 性能优化技巧大全
本文还有配套的精品资源,点击获取 简介:NGUI是Unity中用于构建复杂用户界面的强大系统,UIScrollView是其中用于实现滚动视图的关键组件。文章详细探讨了在移动设备上对UIScrollView进行性能优化的多种方法,包括减少Draw Call、优化Update函数、动态加载内容、使用LoopScrollView、预加载和缓存、利用对象池、深拷贝和浅拷贝的选择、优...
LoopScrollView-Unity
自己实现的循环列表,附带一个工程地址,有Bug随时提 https://github.com/CamelWH/LoopScrollView/tree/main using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; /* 循环列表 -- 格子大小一致的循环列表 -- 通过Template的大小
数据循环拖动表(LoopScrollView)以及跑马灯系统公告使用示例Doem
数据循环拖动表(LoopScrollView)以及跑马灯系统公告
LoopScrollView
Scroll view优化 Demo ,可以动态增删元素,元素可以格式化排列,每行排列个数自定,每个元素中有:按钮(可设置事件监听)、UI赋值等,元素可以循环利用。。。 Demo 中 还 包含查找子物体扩展类。。 只有两个类,使用简单。。 在2019.4.3f1 Unity 版本中, 亲测可用。。
NGUI 无限循环滚动视图:LoopScrollViewForNGUI
LoopScrollViewForNGUI是一个专为NGUI设计的无限循环滚动视图组件,它提供了简单易用的方法来动态添加、删除数据,并且能够自动计算最小循环项目数量,以保证滚动视图的流畅性和性能。
ScrollView实现循环轮播图
Demo实现了一般App首页广告位的图片循环滚动播放功能!
UGUI 无限循环列表
ugui 无限循环列表
ios之UIScrollerView滚动视图总结
UIScrollView 类负责所有基于 UIKit 的滚动操作。 一、创建 CGRect bounds = [ [ UIScreen mainScreen ] applicationFrame ] ; UIScrollView* scrollView = [ [UIScrollView alloc ] initWithFrame:bounds ]; 当你创建完滚动视图后,你可以将另一个视图的内容粘合到滚动视图的空白页上。这回创建一个滚动的内容窗口: [ scrollView addSubview:myView]; 你必须给出内容的实际大小,这样滚动视图才知道滚动的范围: scro
Verilog简易电梯控制系统(2层)
电梯处于1楼,按KEY3,LED3亮,电梯处于上行状态时,立刻按 KEY2,LED2亮,电梯继续运行至2楼,LED3灭;按KEY3,LED3亮,电梯处于上行状态时,立刻按 KEY0,LED0亮,电梯继续运行至2楼,LED3灭;电梯处于2楼,按KEY2,LED2亮,电梯处于下行状态时,立刻按 KEY3,LED3亮,电梯继续运行至1楼,LED2灭;电梯处于2楼,按KEY2,LED2亮,电梯处于下行状态时,立刻按 KEY1,LED1亮,电梯继续运行至1楼,LED2灭;电梯运行至2楼后LED1灭,2楼待机。
[Unity3d][NGUI]自写循环UIScrollView组件. 使用少量Item循环使用.
本组件根据四爷;和Aklan的脚本为基础写的. 转载请注明出处
ESP32固定翼航模硬件设计与飞行力学解析
固定翼无人机是嵌入式控制与空气动力学交叉实践的经典载体,其飞行稳定性本质源于重心、气动中心与控制面的物理耦合关系。理解静稳定度(Static Margin)、升力系数调控、偏航力矩生成等基础原理,是实现可靠姿态控制的前提。在低成本工程约束下,材料刚度、结构弹性与电机-驱动协同设计共同决定了系统动态响应边界。ESP32平台凭借高精度PWM、低功耗双模无线及丰富GPIO,成为教学级航模开发的理想主控;而魔术贴基板、可调电池配重、柔性尾翼等创新结构,则将抽象的飞行力学概念转化为可测量、可调试的实体对象,广泛应用于
开源ZQLoopScrollView轮播组件
ZQLoopScrollView简单易用的图片轮播器,一行代码使用, 希望对大家有帮助。效果图有什么特性我相信你会爱上他!特性1:无缝无限循环滚动我相信每一个想要自己写这个无限滚动显示广告图片的开发者,都会遇到这么个问题:滚动到最后一张后,再切换到第一张时怎么动画效果这么难看呢?根本就是到末尾后就直接切换到第一张,因此效果很不友好。ZQLoopScrollView就很好地解决了这个问题。这个库使用了
ESP8266+Mixly+MIXIO物联网实战:用色盘控制WS2812 RGB灯(附完整代码)
本文详细介绍了如何利用ESP8266微控制器、Mixly图形化编程工具与MIXIO物联网平台,快速构建一个可通过网页色盘远程控制WS2812 RGB智能灯带的实战项目。内容涵盖硬件接线、平台配置、代码编写与调试全流程,旨在帮助物联网爱好者与初学者轻松实现创意灯光应用,掌握智能硬件开发的核心技能。
activemq_CVE-2015-5254_漏洞复现_源码分析
ActiveMQ-CVE-2015-5254
IOS性能实现水平自动无缝循环LoopView(ScrollView)
说明 经常会在app中用到网页上的横向自动滚动的广告效果,
企业级智能问数开发的核心痛点与技术聚焦
本文介绍了企业级智能问数系统开发的三大核心问题和解决方案:语义解析不精准、SQL生成不健壮、企业适配难落地。文章从开发者视角出发,详细拆解了NLU语义解析、SQL生成、对话记忆、企业级适配四大核心模块的技术实现。 在技术选型方面,推荐了LangChain+DeepSeek-R1、FAISS/Milvus、SQLAlchemy等工具链组合。针对企业级需求,重点讲解了: 语义解析模块的意图识别优化和要素提取技术 SQL生成模块的语法校验与性能优化方案 对话记忆模块的Redis存储实现 企业级适配的三层防护体系和
C++实现华容道游戏:面向对象设计与BFS求解算法详解
面向对象编程(OOP)是软件工程的核心范式,它通过封装、继承和多态等机制,将现实世界实体抽象为类和对象,从而构建出高内聚、低耦合的模块化系统。其核心原理在于将数据与操作数据的方法绑定,提升代码的可维护性和复用性。在游戏开发领域,OOP的价值尤为突出,能够清晰地对游戏角色、道具和规则进行建模。以经典的滑块拼图游戏——华容道为例,其实现完美诠释了OOP的应用。通过设计Piece基类及其派生类(如BigSquarePiece、HorizontalPiece)来抽象不同形状的棋子,利用Board类管理棋盘状态与碰撞
SAP 经营范围(Operating Concern) 和业务范围 (Business Area) 在核算架构或是管理架构中的区别和联系分别是什么 请给具体的示例
摘要:SAP系统中,业务范围(Business Area)和经营范围(Operating Concern)在核算架构中具有不同功能。业务范围是FI/CO共用维度,用于跨公司码的业务线核算(如电子产品、机械设备),支持内部管理和简单对外报表。经营范围则是CO-PA专属维度,聚焦获利能力分析,可细化到产品+客户+区域组合(如分析手机在华东区域的获利情况)。两者存在层级关联:经营范围包含业务范围作为基础维度,业务范围数据会传递至经营范围进行深度分析。实际应用中需先配置业务范围,再设置经营范围并关联相关维度,共同支
Python与.NET革命性互操作:PythonNet实现零门槛双向调用——深度解析与实战案例
跨语言调用实战指南:Python与.NET深度集成 摘要:本文详解Python与.NET双向互调技术,通过PythonNet和Python.Runtime实现高效跨语言协作。核心优势包括:无缝集成Python机器学习模块(如PaddleOCR)与.NET UI框架,内存直传提升90%数据效率,减少80%重复代码。内容涵盖:1)Python调用.NET类库的完整流程;2)C#动态加载Python脚本及环境配置要点;3)反射机制实现私有方法调用与泛型处理;4)性能优化技巧(类型缓存、NumPy数组转换);5)异
如何实现图片的无缝循环滚动
如何实现图片的无缝循环滚动作者:haao 日期:2006-05-16解决思路: 一个设定宽度并且隐藏超出它宽度的内容的容器demo,里面放demo1和demo2,demo1是滚动内容,demo2为demo1的直接克隆副本,通过不断改变demo1的scrollTop或者scrollLeft达到滚动的目的,当滚动至demo1与demo2的交界处时直接跳回初始位置,因为
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
vue-seamless-scroll实现无缝上下滚动与左右滚动
上下滚动与左右滚动是我们很常见的一个功能,利用vue-seamless-scroll可以实现上下滚动与左右滚动,其官方网站地址是https://www.npmjs.com/package/vue-seamless-scroll,可以查看其用法。首先查看一下效果图: 一、npm安装 npminstallvue-seamless-scroll--save 二、vue页面引用 (1)imp...
老版QQ原生表情gif动态
这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。
lwip-2.0.3
lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。
iOS 真机不能显示图片问题
华为的C语言编程规范.pdf
华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。
1139



被折叠的 条评论
为什么被折叠?



