首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

iOS:shareSDK第三方登录

shareSDK第三方登录跟分享差不多,比较简单,前面已有介绍。这里简单写一下第三方登录吧。 1、首先:我用到了QQ、微信、新浪这三个平台的登录,需要到它们各自的开发者平台注册开发者账号,这是我的QQ创建应用截图,因为没有导入app的应用图标,所以未审核,但是仍然会生成可用的AppID和App KEY,可以自己接着完善信息提交审核。 2、其次:下载ShareSDK包,将需要的文件导入项目中。这里推荐使用CocoaPods,它可以直接帮助导入所有的依赖库,避免麻烦。我导入的格式如下: pod 'ShareSDK3' pod 'MOBFoundation' pod 'ShareSDK3/ShareSDKPlatforms/QQ' pod 'ShareSDK3/ShareSDKPlatforms/SinaWeibo' pod 'ShareSDK3/ShareSDKPlatforms/WeChat' 3、然后:使用各个平台的appkey或者appid去注册ShareSDK应用,代码如下: @implementation AppDelegate (KJShareSDk) -(void)shareApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ /** * 设置ShareSDK的appKey,如果尚未在ShareSDK官网注册过App,请移步到http://mob.com/login 登录后台进行应用注册, * 在将生成的AppKey传入到此方法中。 * 方法中的第二个第三个参数为需要连接社交平台SDK时触发, * 在此事件中写入连接代码。第四个参数则为配置本地社交平台时触发,根据返回的平台类型来配置平台信息。 * 如果您使用的时服务端托管平台信息时,第二、四项参数可以传入nil,第三项参数则根据服务端托管平台来决定要连接的社交SDK。 */ [ShareSDK registerApp:shareSDK_AppKey activePlatforms:@[ @(SSDKPlatformTypeSinaWeibo), @(SSDKPlatformTypeWechat), @(SSDKPlatformTypeQQ)] onImport:^(SSDKPlatformType platformType) { switch (platformType) { case SSDKPlatformTypeWechat: [ShareSDKConnector connectWeChat:[WXApi class]]; break; case SSDKPlatformTypeQQ: [ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]]; break; case SSDKPlatformTypeSinaWeibo: [ShareSDKConnector connectWeibo:[WeiboSDK class]]; break; default: break; } } onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo) { switch (platformType) { case SSDKPlatformTypeSinaWeibo: //设置新浪微博应用信息,其中authType设置为使用SSO+Web形式授权 [appInfo SSDKSetupSinaWeiboByAppKey:sinaWiebo_AppKey appSecret:sinaWiebo_AppSecret redirectUri:sinaWiebo_RedirectUri authType:SSDKAuthTypeBoth]; break; case SSDKPlatformTypeWechat: [appInfo SSDKSetupWeChatByAppId:wechat_AppId appSecret:wechat_AppSecret]; break; case SSDKPlatformTypeQQ: [appInfo SSDKSetupQQByAppId:qq_AppId appKey:qq_AppKey authType:SSDKAuthTypeBoth]; break; default: break; } }]; } @end 4、接着:去项目中的info下的URL Types设置白名单,用来支持客户端的跳转,参照官方截图如下: 这是我的截图: 6、开始调用集成的方法,进三方登录即可,只要代码如下: 方法一: //例如QQ的登录 [ShareSDK getUserInfo:SSDKPlatformTypeQQ onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) { if (state == SSDKResponseStateSuccess) { NSLog(@"uid=%@",user.uid); NSLog(@"%@",user.credential); NSLog(@"token=%@",user.credential.token); NSLog(@"nickname=%@",user.nickname); //在这里面实现app界面的跳转: 1.如果用户将qq和app已经进行了绑定,直接登录成功就能拿到用户的数据; 2.如果用户没有将qq和app进行绑定,那么绑定成功后就会从服务器获取到token,这个token是用来获取用户数据的,很重要。 总之:每一个用户都有自己唯一的标识,使用第三方登录,第三方是不知道用户的账号和密码的,那么用户必须先绑定,绑定成功后,服务器返回这个标识,之后服务器通过这个标识才能获取到用户的数据。 } else { NSLog(@"%@",error); } }]; 方法二: / 导入头文件 #import <ShareSDKExtension/SSEThirdPartyLoginHelper.h> [SSEThirdPartyLoginHelper loginByPlatform:SSDKPlatformTypeQQ onUserSync:^(SSDKUser *user, SSEUserAssociateHandler associateHandler) { //在此回调中可以将社交平台用户信息与自身用户系统进行绑定,最后使用一个唯一用户标识来关联此用户信息。 //在此示例中没有跟用户系统关联,则使用一个社交用户对应一个系统用户的方式。将社交用户的uid作为关联ID传入associateHandler。 associateHandler (user.uid, user, user); NSLog(@"dd%@",user.rawData); NSLog(@"dd%@",user.credential); } onLoginResult:^(SSDKResponseState state, SSEBaseUser *user, NSError *error) { if (state == SSDKResponseStateSuccess) { } }]; 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/5514805.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:对View添加动画的常用方法

废话少说,直接上代码: -(void) showOrHiddenMenuAndButtomView{ [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.25]; // [UIView setAnimationDelay:0.5]; [UIView setAnimationDelegate:self]; // [UIView setAnimationDidStopSelector:@selector(showMenuStop)]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; if (ismenuViewShow) { ismenuViewShow = NO; // menuView.hidden = YES; // butttomView.hidden = YES; menuView.frame = CGRectMake(0, -60, 1024, 60); butttomView.frame = CGRectMake(0, 748, 1024, 40); } else { ismenuViewShow = YES; // menuView.hidden = NO; // butttomView.hidden = NO; menuView.frame = CGRectMake(0, 0, 1024, 60); butttomView.frame = CGRectMake(0, 708, 1024, 40); } [UIView commitAnimations]; } 本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/11/30/2796796.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:解决动画加阴影卡的问题

self.root.view.layer.shadowColor = [UIColor blueColor].CGColor; self.root.view.layer.shadowOpacity = 0.4f; self.root.view.layer.shadowOffset = CGSizeMake(-12.0, 1.0f); self.root.view.layer.shadowRadius = 7.0f; self.root.view.layer.masksToBounds = NO; 用上面代码对有动画的view加了阴影,会有卡顿的现象。 要设置一下path: [UIBezierPath bezierPathWithRect:_toView.bounds].CGPath; self.root.view.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.root.view.bounds].CGPath; self.root.view.layer.shadowColor = [UIColor blueColor].CGColor; self.root.view.layer.shadowOpacity = 0.4f; self.root.view.layer.shadowOffset = CGSizeMake(-12.0, 1.0f); self.root.view.layer.shadowRadius = 7.0f; self.root.view.layer.masksToBounds = NO; 卡顿消失。 check:http://blog.csdn.net/mkhgg/article/details/7286282 本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/11/22/2783438.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS: 悬浮的条件筛选框使用二

一、介绍: 在前面已经介绍了一种条件悬浮框,使用的是tableView的Plain分组样式实现的,因为这是tableView本身就具备的功能,分组悬浮效果。这次我来介绍第二种更加简单的方法,采用两个ScrollView来实现。 二、实现技术: (1)两个ScrollView,一个是左右滚动,成为内容视图,另一个是上下滚动,作为容器视图; (2) 创建头视图,头视图中有banner图和条件筛选框,标记banner图的高; (3)合理设置上下滚动的容器视图的frame,它承载头视图和内容视图,不过需要禁止它的弹簧效果,实现悬浮框功能。 三、代码如下: HeadView.h // HeadView.h // SuspensionViewDemo // // Created by 夏远全 on 16/11/25. // Copyright © 2016年 广州市东德网络科技有限公司. All rights reserved. // #import <UIKit/UIKit.h> @interface HeadView : UIView /** * 类方法创建头视图 */ +(instancetype)createHeadView:(CGRect)frame; @property (strong,nonatomic)UIView *animationView; //下划线动画视图 @end HeadView.m View Code ContentView.h // ContentView.h // SuspensionViewDemo // // Created by 夏远全 on 16/11/25. // Copyright © 2016年 广州市东德网络科技有限公司. All rights reserved. // #import <UIKit/UIKit.h> @interface ContentView : UIScrollView //类方法创建 +(instancetype)shareWithFrame:(CGRect)frame; @end ContentView.m // ContentView.m // SuspensionViewDemo // // Created by 夏远全 on 16/11/25. // Copyright © 2016年 广州市东德网络科技有限公司. All rights reserved. // #import "ContentView.h" #define XYQColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] #define XYQRandomColor XYQColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256)) #define SCREEN_W [[UIScreen mainScreen] bounds].size.width #define SCREEN_H [[UIScreen mainScreen] bounds].size.height @implementation ContentView //初始化 -(instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { //放tableView for (int i=0; i<4; i++) { UIImageView *imgViw = [[UIImageView alloc]init]; imgViw.backgroundColor = XYQRandomColor; imgViw.frame = CGRectMake(SCREEN_W*i, 0, SCREEN_W, SCREEN_H-110); [self addSubview:imgViw]; } } return self; } //类方法创建 +(instancetype)shareWithFrame:(CGRect)frame{ ContentView *contentView = [[self alloc]initWithFrame:frame]; contentView.contentSize = CGSizeMake(SCREEN_W*4,frame.size.height); contentView.pagingEnabled = YES; contentView.bounces = NO; return contentView; } @end ViewController.h // ViewController.h // SuspensionViewDemo // // Created by 夏远全 on 16/11/25. // Copyright © 2016年 广州市东德网络科技有限公司. All rights reserved. // #import <UIKit/UIKit.h> #import "ContentView.h" @interface ViewController : UIViewController /** * 内容视图 */ @property (strong,nonatomic)ContentView *contentView; @end ViewController.m View Code 四、演示截图:(上拉到顶就悬浮了不能在上拉,下拉可以继续),点击按钮来回切换tableView 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/6103168.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:简易的音视屏播放框架XYQPlayer

一、前缀 一直都想好好学学音视频这方面的知识,抽了几个周末参考一些资料,尝试着写了一个简易的音视频播放框架,支持音视频播放、视频截图、音乐缓存,其实吧,也就是尽可能的封装罢了,方便以后自己使用。目前只是开始,可能有些不足,后续会继续优化。可以在github上下载,地址是https://github.com/xiayuanquan/XYQPlayer,当然也请多多关注本博主夏远全。 概念参考我的这篇博文:http://www.cnblogs.com/XYQ-208910/p/5662655.html 二、框架 1、截图 2、文件 XYQAllHeader.h:所有的头文件 View Code XYQAudioTool.h/m:音频播放工具类,播放包括短音频和音乐 View Code XYQAudioToolView.h/m:音频播放界面类,显示播放音乐的界面,播放、暂停、光盘旋转 View Code XYQAudioToolLoader.h/m:音频下载类,缓存音乐到本地 View Code XYQMovieTool.h/m:视频播放工具类,直接显示播放界面、还有截屏功能 View Code XYQCachesManager.h/.m:缓存管理类,计算缓存大小、清除缓存 View Code XYQHUDView.h/m:弹框提示,包括文本提示、下载进度提示 View Code XYQTimeProgress.h/m:音乐播放时间进度条 View Code UIImage+XYQCornerRadius.h/m:对图片进行处理的类 View Code Source.bundle:资源包,存放图片icon 3、依赖 三、音乐播放和缓存逻辑 四、视频播放方式 五、音频播放test #import "PlayMusicViewController.h" #import "XYQAllHeader.h" @interface PlayMusicViewController () @property (strong,nonatomic)XYQAudioToolView *audioPlayerView; @end @implementation PlayMusicViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"清除缓存" style:UIBarButtonItemStylePlain target:self action:@selector(clearCache)]; //1、网络音乐(此处需要给出准确的url,我的这个不可以用,只是给个参考的样式) //[self testPlay_Local_URL_Music:@[@"http://120.25.226.186:32812/xxx/minion_02.mp3"]]; //2、本地音乐 [self testPlay_Bundle_Music:[self musicArray]]; } //测试创建音乐播放器(播放沙盒本地音乐包括从网络音乐下载缓存) - (void)testPlay_Local_URL_Music:(NSArray *)musicFileLinkArray{ self.audioPlayerView = [XYQAudioToolView openAudioPlayerView:musicFileLinkArray audioPlayerViewController:self]; self.audioPlayerView.diskIsHide = YES; } //测试创建音乐播放器(播放bundle根目录下的音乐) - (void)testPlay_Bundle_Music:(NSArray *)musicNameArray{ self.audioPlayerView = [XYQAudioToolView openAudioPlayerView:musicNameArray audioPlayerViewController:self]; self.audioPlayerView.diskIsHide = YES; } //Bundle根目录子下所有的音乐文件名 - (NSArray *)musicArray{ NSString *path = [[NSBundle mainBundle] pathForResource:@"Musics" ofType:@"plist"]; NSArray *musicNameArr = [NSArray arrayWithContentsOfFile:path]; return musicNameArr; } //清除缓存 - (void)clearCache{ [XYQCachesManager clearFileCaches]; } //关闭播放器 -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.audioPlayerView dismissAudioPlayerView]; } 六、视频播放test // // PlayMovieViewController.m // XYQPlayer // // Created by 夏远全 on 2017/4/9. // Copyright © 2017年 夏远全. All rights reserved. // #import "PlayMovieViewController.h" #import "XYQAllHeader.h" @interface PlayMovieViewController () @end @implementation PlayMovieViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; //1、push视频 [XYQMovieTool pushPlayMovieWithNetURL:@"http://120.25.226.186:32812/resources/videos/minion_02.mp4" viewController:self]; } -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //2、present视频 //[XYQMovieTool presentPlayMovieWithNetURL:@"http://120.25.226.186:32812/resources/videos/minion_02.mp4" viewController:self]; } //关闭播放器 -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [XYQMovieTool cancelPlay]; } @end 七、演示截图 音乐: 视频: push: present: 八、cocoaPods支持: pod search 'XYQPlayer' 九、声明 本博文为原创,如转载请注明出处,希望对大家有所帮助~~~~ cnblogs地址:http://www.cnblogs.com/XYQ-208910/p/6685412.html github地址:https://github.com/xiayuanquan/XYQPlayer 简书地址:http://www.jianshu.com/p/1f8f434cfcba 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/6685412.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:UIScrollView控件和UIPageControl控件的详解

UIScrollView滚动视图控件和UIPageControl分页视图控件: UIScrollView用于显示多于一个屏幕的内容,超出屏幕范围的内容可以通过滑动进行查看,当然UIPagecontrol也能实现图片分页查看。 UIScrollView往往搭配UIPageControl一起使用,当UIScrollView进行滚动查看时,UIPagecontrol对应的分页控制点也会相应的变动,反之亦然。 获取当前分页的页码: //页码 = (contentoffset.x + scrollView一半宽度)/单个scrollView宽度 //页码=滚动视图可以滚动的总宽度/单个滚动视图的宽度) 一、 UIScrollView常见属性: @interface UIScrollView : UIView <NSCoding> { @property(nonatomic) CGPointcontentOffset;//UIScrollView当前滚动的位置 @property(nonatomic)CGSizecontentSize; //设置UIScrollView的滚动范围(滚动图大小) @property(nonatomic)UIEdgeInsetscontentInset; //这个属性可以在四周增加滚动范围(即增减周边空白部分) @property(nonatomic,assign)id<UIScrollViewDelegate>delegate;//滚动视图的代理 @property(nonatomic,getter=isDirectionalLockEnabled) BOOL directionalLockEnabled; //控件是否只在一个方向滚动 @property(nonatomic) BOOL bounces; //是否有弹簧效果 @property(nonatomic) BOOL alwaysBounceVertical;//设置垂直方向的弹簧效果 @property(nonatomic)BOOL alwaysBounceHorizontal;//设置水平方向的弹簧效果 @property(nonatomic,getter=isPagingEnabled)BOOLpagingEnabled;//控制控件是否整页翻动 @property(nonatomic,getter=isScrollEnabled)BOOLscrollEnabled; //是否能滚动 @property(nonatomic) BOOL showsHorizontalScrollIndicator; //是否显示水平方向的滚动条 @property(nonatomic)BOOL showsVerticalScrollIndicator; //是否显示垂直方向的滚动条 @property(nonatomic)UIEdgeInsetsscrollIndicatorInsets;//设置滚动范围 @property(nonatomic)UIScrollViewIndicatorStyle indicatorStyle; //设置滚动条样式 @property(nonatomic) CGFloat decelerationRate ; //设置手指放开后的减速率 @property(nonatomic) CGFloat zoomScale //放缩比例 @property(nonatomic) BOOL bouncesZoom //是否实现所给的弹簧比例 @property(nonatomic) BOOL scrollsToTop //是否能够滚动到顶部 }@end UIScrollView常见方法: - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; //以恒定速度为动画设置新的偏移量 - (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated; //设置由rect定义的区域仅仅是滚动视图内是可见的 - (void)flashScrollIndicators; //闪一下滚动条,暗示是否有可滚动的内容 二、UIScrollView手势缩放 设置UIScrollView的id<UISCrollViewDelegate> delegate代理对象 设置minimumZoomScale:缩小的最小比例 设置maximumZoomScale:放大的最大比例 让代理对象实现下面的方法,返回需要缩放的视图控件 -(UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView 跟缩放相关的常用方法还有 -(void)scrollViewDidZoom:(UIScrollView*)scrollView正在缩放的时候调用 -(void)scrollViewDidEndZooming:(UIScrollView*)scrollViewwithView:(UIView*)viewatScale:(float)scale缩放完毕的时候调用 三、UIPagecontrol分页效果 设置pagingEnabled=YES即可,UIScrollView会被分割成多个独立页面,用户的滚动体验则变成了页面翻转 一般会配合UIPageControl增强分页效果 UIPageControl常用属性: NSIntegernumberOfPages:总页数 NSIntegercurrentPage:当前的页码 BOOLhidesForSinglePage:当只有一页的时候,是否要隐藏视图 @property(nonatomic,retain)UIColor*pageIndicatorTintColor;设置控制器页码点得颜色 @property(nonatomic,retain)UIColor*currentPageIndicatorTintColor;设置控制器当前所在页码点的颜色 监听UIPageControl的页面改变: //添加监听器 [pageControladdTarget:selfaction:@selector(pageChange:) forControlEvents:UIControlEventValueChanged]; //监听方法 - (void)pageChange:(UIPageControl*)pageControl { } 四、UIScrollView滚动视图要实现的协议:UIScrollViewDelegate @protocol UIScrollViewDelegate<NSObject> @optional - (void)scrollViewDidScroll:(UIScrollView*)scrollView;//正在执行滚动视图的滚动操作时调用 - (void)scrollViewDidZoom:(UIScrollView *)scrollView ;//正在执行滚动视图的放缩操作时调用 - (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView;//执行滚动视图的拖拽开始时调用 - (void)scrollViewWillEndDragging:(UIScrollView*)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inoutCGPoint*)targetContentOffset;//执行滚动视图的拖拽结束时调用 - (void)scrollViewDidEndDragging:(UIScrollView*)scrollView willDecelerate:(BOOL)decelerate;//执行滚动视图的拖拽结束时调用(是否减速) - (void)scrollViewWillBeginDecelerating:(UIScrollView*)scrollView;//执行滚动视图减速开始时调用 - (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView;// 执行滚动视图减速结束时调用 - (void)scrollViewDidEndScrollingAnimation:(UIScrollView*)scrollView;//滚动视图动画结束时调用 - (UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView;//执行滚动视图放缩时返回新的视图 - (void)scrollViewWillBeginZooming:(UIScrollView*)scrollView withView:(UIView*)view;//滚动视图放缩开始时调用 - (void)scrollViewDidEndZooming:(UIScrollView*)scrollView withView:(UIView*)view atScale:(CGFloat)scale;//滚动视图放缩结束时调用 - (BOOL)scrollViewShouldScrollToTop:(UIScrollView*)scrollView;//滚动视图是否滚动到顶部 - (void)scrollViewDidScrollToTop:(UIScrollView*)scrollView; //滚动视图滚动到顶部时调用 @end 代码范例解析: 一、单张图片案例: (1) //设置imageView,获取图片资源 UIImage *img = [UIImage imageNamed:@"landscape.jpg"]; self.imageview = [[UIImageView alloc]init]; [self.imageview setImage:img]; self.imageview.contentMode = UIViewContentModeScaleAspectFit;//防止图片在变换的过程中失真 self.imageview.frame = CGRectMake(0, 0, img.size.width, img.size.height); //设置scrollView(位置和大小即origin.x 、origin.y、 size.width 、size.height) self.scrollview.contentSize = img.size;//直接将滚动视图中存放内容的范围大小设置为图片的大小 self.scrollview.contentOffset = CGPointZero;//默认origin.x = 0,orgin.y = 0 //弹簧效果(所谓弹簧效果就是不论图片被拽托到滚动图内那儿松开后都会返回原来的位置上) self.scrollview.bounces = NO; //添加四条边距(相当于相框部分) self.scrollview.contentInset = UIEdgeInsetsMake(10, 10, 10, 10); //滚动效果(图片太大时,能否拖拽着移动查看其他部分) self.scrollview.scrollEnabled = YES; //滚动条的设置(类似于滑块,有上下滑动的,也有左右滑动的) //self.scrollview.showsHorizontalScrollIndicator = NO;//水平方向 //self.scrollview.showsVerticalScrollIndicator = NO; //垂直方向 //设置滚动条的样式 self.scrollview.indicatorStyle = UIScrollViewIndicatorStyleBlack; //将视图添加到滚动视图中 [self.scrollview addSubview:self.imageview]; //将视图设置到滚动视图最后面(如果在滚动视图上添加其他的控件如UIButton,采取这种方式可以避免button控件被图片遮盖) [self.scrollview sendSubviewToBack:self.imageview]; //设置滚动视图的代理 self.scrollview.delegate = self; //设置滚动视图的放大和缩小的系数 self.scrollview.minimumZoomScale = 0.8; self.scrollview.maximumZoomScale = 2.0; //将滚动视图添加到视图中 [self.view addSubview:self.scrollview]; //添加按钮事件来滚动图片 - (IBAction)buttonClicked:(UIButton *)sender { CGPoint point = self.scrollview.contentOffset; self.scrollview.contentOffset = CGPointMake(point.x+20, point.y); } //代理实现UIScrollView的方法 #pragma mark - UIScrollView - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView//实现图片的放缩 { return self.imageview; } -(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale { NSLog(@"view:%@,scale:%f",view,scale);//输出放缩后的视图信息和放缩系数 } 二、图片轮转播放器案例: 具体代码如下: 1 #import "ViewController.h" 2 3 @interface ViewController ()<UIScrollViewDelegate> //实现滚动视图协议 4 @property (strong,nonatomic)UIScrollView *scrollview; //滚动视图控件对象 5 @property (strong,nonatomic)UIPageControl *pagecontrol;//分页控制控件对象 6 @end 7 8 @implementation ViewController 9 10 - (void)viewDidLoad { 11 [super viewDidLoad]; 12 //创建ScrollView并初始化 13 self.scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 14 //将滚动视图添加到视图控制器控制的视图View容器中 15 [self.view addSubview:self.scrollview]; 16 17 18 //创建5个imageView对象并加载图片 19 CGFloat x = 0; 20 CGFloat y = 0; 21 UIImage *image; 22 for(int i=0; i<5; i++) 23 { 24 UIImageView *imageview = [[UIImageView alloc]init]; 25 image = [UIImage imageNamed:[NSString stringWithFormat:@"s%d.jpg",i+1]]; 26 [imageview setImage:image]; 27 //设置每一个图像视图imageView的frame矩形区域 28 imageview.frame = CGRectMake(x+self.view.frame.size.width*i, y, self.view.frame.size.width, image.size.height); 29 //设置图像模式,使图片变动时,图片不失真 30 imageview.contentMode = UIViewContentModeScaleAspectFit; 31 //将图像视图添加到滚动视图容器中 32 [self.scrollview addSubview:imageview]; 33 } 34 35 //设置scrollView 36 self.scrollview.contentSize = CGSizeMake(5*self.view.frame.size.width, self.view.frame.size.height);//有多少图片,那么滚动视图的滚动宽度就等于图片数量乘以你所设置的单个滚动视图矩形区域的宽度 37 self.scrollview.contentOffset = CGPointZero;//默认滚动视图的初始原点位置都为0 38 self.scrollview.pagingEnabled = YES;//设置滚动视图可以进行分页 39 self.scrollview.delegate = self;//设置滚动视图的代理 40 41 //创建初始化并设置PageControl 42 self.pagecontrol = [[UIPageControl alloc]init]; 43 self.pagecontrol.bounds = CGRectMake(0, 0, 100, 50); 44 self.pagecontrol.center = self.view.center; 45 self.pagecontrol.numberOfPages = 5; //因为有5张图片,所以设置分页数为5 46 self.pagecontrol.currentPage = 0; //默认第一页页数为0 47 //设置分页控制点颜色 48 self.pagecontrol.pageIndicatorTintColor = [UIColor redColor];//未选中的颜色 49 self.pagecontrol.currentPageIndicatorTintColor = [UIColor greenColor];//选中时的颜色 50 //添加分页控制事件用来分页 51 [self.pagecontrol addTarget:self action:@selector(pageControlChanged:) forControlEvents:UIControlEventValueChanged]; 52 //将分页控制视图添加到视图控制器视图中 53 [self.view addSubview:self.pagecontrol]; 54 //设置试图控制器背景色为黑色 55 self.view.backgroundColor = [UIColor blackColor]; 56 } 57 #pragma mark - pageControll的事件响应 58 -(void)pageControlChanged:(UIPageControl*)sender 59 { 60 /* 61 //NSLog(@"%ld",sender.currentPage); 62 CGRect frame; 63 frame.origin.x = self.scrollview.fram 64 e.size.width * sender.currentPage; 65 frame.origin.y = 0; 66 frame.size = self.scrollview.frame.size; 67 [self.scrollview scrollRectToVisible:frame animated:YES]; 68 */ 69 或者 70 //计算scrollview相应地contentOffset 71 CGFloat x = sender.currentPage * self.scrollview.frame.size.width; 72 self.scrollview.contentOffset = CGPointMake(x,0); 73 74 } 75 76 #pragma mark - scrollView的代理方法 77 -(void)scrollViewDidScroll:(UIScrollView *)scrollView 78 { 79 //计算pagecontroll相应地页(滚动视图可以滚动的总宽度/单个滚动视图的宽度=滚动视图的页数) 80 NSInteger currentPage = (int)(scrollView.contentOffset.x) / (int)(self.view.frame.size.width); 81 self.pagecontrol.currentPage = currentPage;//将上述的滚动视图页数重新赋给当前视图页数,进行分页 82 } 83 @end 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/4781845.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:集成环信EaseMobSDK单聊功能

当然在集成环信之前需要一些准备操作: 1、首先注册环信开发者账号,直接进入环信官网注册即可:http://www.easemob.com 2、按照文档一步一步将需要的文件全部拖入工程中:http://docs.easemob.com/start/start 以下是我集成的文件:使用 EaseUI集成:http://docs.easemob.com/start/300iosclientintegration/140easeuiuseguide libEaseMobClientSDK.a包 ChatDemo-UI3.0中的ChatView中的聊天控制器 我主要使用EaseMob中这个EaseSDKHelper单例类来注册、登录、获取最新消息、推送等 在App启动程序时: 进入EaseSDKHelper单例类中,添加一些自定义的方法 View Code 在会话列表控制器中: View Code 在聊天控制器中,直接集成ChatViewController View Code 在自定义的会话列表cell中,显示会话联系人、最后一条记录、时间 View Code 消息提醒按钮 View Code 最后在TabbarController中检测未读消息 //首先得注册代理,监听未读消息数 [[EaseMob sharedInstance].chatManager addDelegate:self delegateQueue:nil]; View Code //移除代理 -(void)dealloc{ [[EaseMob sharedInstance].chatManager removeDelegate:self]; } 测试后: 以上只是实现了单聊和群聊的功能,那么实时语音和视频如何实现呢,下面这个就是干货: 1.集成实时通话的前提是集成好单聊,并且使用的是libEaseMobClientSDK.a包,因为这个包 包含实时通话的功能2.将demo3.0中的Call文件(实时通话的界面)以及Resources(通话界面的资源图片)加到你自己的工程中3.点击实时通话或者视频的按钮,实际是发起的通知,在你工程中的主控制器中监听这个通知,在通知的方法中实现发起实时通话的方法以及跳转到通话界面4.接收实时通话的回调是 - (void)callSessionStatusChanged:(EMCallSession *)callSession changeReason:(EMCallStatusChangedReason)reason error:(EMError *)error 5.实时通话用的协议是:EMCallManagerDelegate 代理:[[EaseMob sharedInstance].callManager addDelegate:self delegateQueue:nil];6.具体添加哪些方法看下上传的ViewController文件,按照这个文件中的方法加到自己的主控制器中,demo中的实现在MainViewController.m类 代码如下: 记得先导入call文件:这个是用来进行视频和电话语音的类 ViewController.docx文件:http://i.cnblogs.com/Files.aspx View Code 演示结果如下:经本人测试,在真机上运行没有问题,实时语音视频聊天均能够实现 左边为电话通话 右边为视频通话 以下为参考资料: 1.基于环信Demo3.0,实现单聊功能:http://www.jianshu.com/p/f53be9664f14 2.集成环信的即时通讯:http://www.jianshu.com/p/b4618ef39274 3.环信聊天界面 - 显示历史会话记录:http://blog.csdn.net/github_26672553/article/details/50719487 4.环信集成 - 加载会话列表:http://blog.csdn.net/u010545480/article/details/49660255 5.扩展表情包:http://apps.timwhitlock.info/emoji/tables/unicode 其他demo下载:https://github.com/zyprosoft/ZYChat 集成视频:http://www.imgeek.org/video/ github:https://github.com/xiayuanquan/EaseMobChat 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/5396635.html,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码