我使用的是友盟上集成的第三方登录功能,一共使用了三个应用的登录授权,QQ、微信、新浪微博。由于第三方登录授权成功后,需要跳转到一个新的界面,所以这里需要在项目里设置第三方登录的SSO授权。就是必须安装了相关的手机客户端后,才能使用第三方登录,在使用第三方登录时,我们需要先判断一下 ...
我使用的是友盟上集成的第三方登录功能,一共使用了三个应用的登录授权,QQ、微信、新浪微博。由于第三方登录授权成功后,需要跳转到一个新的界面,所以这里需要在项目里设置第三方登录的SSO授权。就是必须安装了相关的手机客户端后,才能使用第三方登录,在使用第三方登录时,我们需要先判断一下用户手机上是否已经安装了对应的应用。
一、集成SSO授权
这里集成SSO授权的方法我就不详细讲解了,因为还涉及到注册第三方平台帐号这些琐屑的事。下面我给一个友盟上集成SSO授权的地址,文档说明都是很详细的
地址:http://dev.umeng.com/social/ios/detail-share#6 如果你中途遇到任何问题,都可以在这里留言,接下去我主要是贴代码和实现效果截图。
二、对应控件的布局代码
1 NSArray *imageArray=[[NSArray alloc]initWithObjects:@"btn_3_weixin",@"btn_3_qq",@"btn_3_weibo", nil]; 2 UIImageView *shareButton; 3 CGFloat firstButtonWdith=0; 4 CGFloat axisY=functionButton.frame.origin.y+functionButton.frame.size.height+40; 5 CGFloat thisWidht=DEVICE_Width-76; 6 7 UILabel *thisShareLabel; 8 for (int sh=0;sh<3;sh++) { 9 shareButton=[[UIImageView alloc]init];10 if (sh==0) {11 thisShareLabel=[[UILabel alloc]initWithFrame:CGRectMake(38, axisY+7, thisWidht*0.25, 1)];12 thisShareLabel.backgroundColor=[UIColor whiteColor];13 shareButton.frame = CGRectMake( thisShareLabel.frame.origin.x+thisShareLabel.frame.size.width*0.18 , thisShareLabel.frame.origin.y+20,thisShareLabel.frame.size.width*0.64 , thisShareLabel.frame.size.width*0.64);14 15 firstButtonWdith=shareButton.frame.size.width;16 17 }18 else if(sh==1)19 {20 thisShareLabel=[[UILabel alloc]initWithFrame:CGRectMake(thisShareLabel.frame.size.width+thisShareLabel.frame.origin.x, axisY, thisWidht*0.5, 14)];21 thisShareLabel.text=@"第三方账户登录";22 23 shareButton.frame = CGRectMake( thisShareLabel.frame.origin.x+thisShareLabel.frame.size.width/2-(firstButtonWdith/2) , thisShareLabel.frame.origin.y+26,firstButtonWdith, firstButtonWdith);24 25 }26 else27 {28 thisShareLabel=[[UILabel alloc]initWithFrame:CGRectMake(thisShareLabel.frame.size.width+thisShareLabel.frame.origin.x, axisY+7, thisWidht*0.25, 1)];29 thisShareLabel.backgroundColor=[UIColor whiteColor];30 31 shareButton.frame = CGRectMake( thisShareLabel.frame.origin.x+thisShareLabel.frame.size.width*0.18 , thisShareLabel.frame.origin.y+20,thisShareLabel.frame.size.width*0.64 , thisShareLabel.frame.size.width*0.64);32 }33 thisShareLabel.font=[UIFont systemFontOfSize:14];34 thisShareLabel.textAlignment=NSTextAlignmentCenter;35 thisShareLabel.textColor=[UIColor whiteColor];36 [self addSubview:thisShareLabel];37 38 [shareButton setImage:[UIImage imageNamed:[imageArray objectAtIndex:sh]]];39 shareButton.userInteractionEnabled=YES;40 UIGestureRecognizer *thirdSDKLoginUIGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(thirdSDKLogin:)];41 [shareButton addGestureRecognizer:thirdSDKLoginUIGestureRecognizer];42 shareButton.tag=123456+sh;43 [self addSubview:shareButton];44 if (sh==2) {45 self.backScrollView .scrollEnabled=YES;46 if (DEVICE_Height<500) {47 [self.backScrollView setContentSize:CGSizeMake(DEVICE_Width, self.backScrollView.contentSize.height+50)];48 }49 }50 51 52 }
原标题:IOS 集成第三方登录
关键词:IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。