自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

geeklyc

成长路上

  • 博客(7)
  • 资源 (4)
  • 收藏
  • 关注

原创 使用FMDataBase

iOS中原生的SQLite API在使用上相当不友好,在使用时,非常不便。于是,就出现了一系列将SQLite API进行封装的库,例如FMDB、PlausibleDatabase、sqlitepersistentobjects等,FMDB (https://github.com/ccgus/fmdb) 是一款简洁、易用的封装库,这一篇文章简单介绍下FMDB的使用。在FMDB下载文件

2014-12-25 09:39:01 561

原创 iOS形成静态库方法

在iOS的开发过程中,我们常常用到第三方的库。尤其是QQ、百度地图、广告等。那么,如何制作自己的库文件呢?如果,将自己写的功能类编译成库文件,分发给其他人来使用呢?静态库的优点编译静态库的好处也还是有的!1.让自己的源码不被直接暴漏。2.需要使用时,仅仅拷贝相应的.h文件和.a文件就好,不用在将源码一一拷贝。方便。3.

2014-12-23 10:27:26 426

原创 iOS 汉字转拼音

在这里我引用了第三方的东西(email:summer2014mht@sina.com):在这里我采用了两种方式(方式二简单,方便使用):- (NSString *)pinYin{//方式一//先转换为带声调的拼音NSMutableString *str = [self mutableCopy];CFStringTransform((C

2014-12-20 18:43:52 422

原创 CocoaAsyncSocket学习

下载地址:https://github.com/robbiehanson/CocoaAsyncSocket(必须使用arc项目)CocoaAsyncSocket支持tcp和udp。其中:AsyncSocket类是支持TCP的AsyncUdpSocket是支持UDP的AsyncSocket是封装了CFSocket和CFSteam的TCP/IP socket网络库。它提

2014-12-20 18:37:03 441

原创 AsyncSocket使用心得

倒入runloop文件夹下的 四个文件即可AsyncSocket *socket=[[AsyncSocketalloc]initWithDelegate:self]; NSError *error; [socket  connectToHost:h onPort:p withTimeout:-1error:&error ];  然后实现一些Del

2014-12-20 17:59:28 556

原创 iOS的Asyncsocket进行socket编程

iphone的标准推荐CFNetwork C库编程.但是编程比较烦躁。在其它OS往往用类来封装的对Socket函数的处理。比如MFC的CAsysncSocket.在iphone也有类似于开源项目.cocoa AsyncSocket库, 官方网站:http://code.google.com/p/cocoaasyncsocket/ 它用来简化CFnetwork的调用.一.在项目引入ASync

2014-12-20 17:51:14 448

原创 AsyncSocket常用方法解释

AsynSocket常用方法解释//在socket连结发生错误的时候,socket被关闭。//在断开之前你可以读取断开之前最后的bit数据//当连接的时候,这个代理的方法可能被执行。-(void) onSocket:(AsyncSocket *) sock willDisConnectWithError:(NSError *)err;//当socket断开或者没有错

2014-12-20 17:41:02 800

Swift-开发者必备Tips

单例 闭包 泛型拓展 Core Data 断言和异常处理 JSON和Codeable

2018-10-11

Swift-App架构

介绍 App设计模式概览 Model-View-Controller Model-View-ViewModel+协调器(MVVM-C) 网络 Model-View-Controller+ViewState Model适配器-View绑定器

2018-10-11

UIScrollView图片定时滚动和点击

UIScrollView图片定时滚动和点击

2014-07-02

UIScrollView定时滚动和循环滚动,可点击图片和PageController

定时滚动和循环滚动,可点击图片和PageController #import "ASIFormDataRequest.h" #import "GWPublicClass.h" @interface ViewController ()<UIScrollViewDelegate> @end @implementation ViewController { UIScrollView * headScrollView; UIPageControl * pageControl; NSArray * colorArray; NSTimer * myTimer; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } #pragma UIScrollView delegate -(void)scrollToNextPage:(id)sender { int pageNum = pageControl.currentPage; CGSize viewSize = headScrollView.frame.size; CGRect rect = CGRectMake((pageNum+2)*viewSize.width, 0, viewSize.width, viewSize.height); [headScrollView scrollRectToVisible:rect animated:NO]; pageNum++; if (pageNum == colorArray.count) { CGRect newRect=CGRectMake(viewSize.width, 0, viewSize.width, viewSize.height); [headScrollView scrollRectToVisible:newRect animated:NO]; } } -(void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat pageWidth = headScrollView.frame.size.width; int currentPage = floor((headScrollView.contentOffset.x-pageWidth/2)/pageWidth)+1; if (currentPage == 0) { pageControl.currentPage = colorArray.count-1; }else if(currentPage == colorArray.count+1){ pageControl.currentPage=0; } pageControl.currentPage = currentPage-1; } -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [myTimer invalidate]; } -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { myTimer=[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(scrollToNextPage:) userInfo:nil repeats:YES]; } -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGFloat pageWidth = headScrollView.frame.size.width; CGFloat pageHeigth = headScrollView.frame.size.height; int currentPage=floor((headScrollView.contentOffset.x-pageWidth/2)/pageWidth)+1; NSLog(@"the current offset==%f",headScrollView.contentOffset.x); NSLog(@"the current page==%d",currentPage); if (currentPage == 0) { [headScrollView scrollRectToVisible:CGRectMake(pageWidth*colorArray.count, 0, pageWidth, pageHeigth) animated:NO]; pageControl.currentPage = colorArray.count-1; NSLog(@"pageControl currentPage==%d",pageControl.currentPage); NSLog(@"the last image"); return; }else if(currentPage == [colorArray count]+1){ [headScrollView scrollRectToVisible:CGRectMake(pageWidth, 0, pageWidth, pageHeigth) animated:NO]; pageControl.currentPage=0; NSLog(@"pageControl currentPage==%d",pageControl.currentPage); NSLog(@"the first image"); return; } pageControl.currentPage=currentPage-1; NSLog(@"pageControl currentPage==%d",pageControl.currentPage); } - (void)pageTurn:(UIPageControl *)sender { int pageNum = pageControl.currentPage; CGSize viewSize = headScrollView.frame.size; [headScrollView setContentOffset:CGPointMake((pageNum+1)*viewSize.width, 0)]; NSLog(@"myscrollView.contentOffSet.x==%f",headScrollView.contentOffset.x); NSLog(@"pageControl currentPage==%d",pageControl.currentPage); [myTimer invalidate]; } - (void)handleTapGesture:(UITapGestureRecognizer*)gesture { NSLog(@"UITapGesture被调用了%d",gesture.view.tag); // ... } - (void)viewDidLoad { [super viewDidLoad]; colorArray = @[[UIColor redColor],[UIColor greenColor],[UIColor blueColor]]; headScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 80, 320, 200)]; headScrollView.backgroundColor = [UIColor blackColor]; [self.view addSubview:headScrollView]; CGFloat Width= 320; CGFloat Height= 200; UIImageView * firstImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, Width, Height)]; firstImageView.userInteractionEnabled = YES; firstImageView.tag = 50+colorArray.count-1; firstImageView.backgroundColor = colorArray[colorArray.count-1]; [headScrollView addSubview:firstImageView]; UITapGestureRecognizer * gestd = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; [firstImageView addGestureRecognizer:gestd]; for (int i=0; i<colorArray.count; i++) { UIImageView * subImageView=[[UIImageView alloc] initWithFrame:CGRectMake(Width*(i+1), 0, Width, Height)]; subImageView.backgroundColor = colorArray[i]; subImageView.userInteractionEnabled = YES; subImageView.tag = 50+i; subImageView.frame=CGRectMake(Width*(i+1), 0, Width, Height); [headScrollView addSubview: subImageView]; UITapGestureRecognizer * gestd = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; [subImageView addGestureRecognizer:gestd]; } UIImageView * lastImageView = [[UIImageView alloc] initWithFrame:CGRectMake(Width*(colorArray.count+1), 0, Width, Height)]; lastImageView.userInteractionEnabled = YES; lastImageView.backgroundColor = colorArray[0]; lastImageView.tag = 50; [headScrollView addSubview:lastImageView]; headScrollView.contentSize = CGSizeMake(Width*(colorArray.count+2), Height); headScrollView.pagingEnabled = YES; headScrollView.delegate = self; [headScrollView scrollRectToVisible:CGRectMake(Width, 0, Width, Height) animated:YES]; pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 290, 120, 20)]; pageControl.numberOfPages = colorArray.count; pageControl.backgroundColor = [UIColor greenColor]; pageControl.enabled = YES; pageControl.currentPage = 0; [pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:pageControl]; myTimer=[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(scrollToNextPage:) userInfo:nil repeats:YES]; } - (void)enterDetail { NSLog(@"tap is "); }

2014-07-02

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除