iOS学习之iOS5.0以上使用新浪微博…

继上篇 iOS学习之iOS5.0以上 使用新浪微博开放平台OAuth

过后,新浪微博授权弹出的网页又有调整,中间还有过瘫痪情况。如果按上篇做出来的授权页面就成这样了:


 

第一:网页页面变大了,

第二:没有了取消按钮。


根据这个情况在sina weibo SDK里做了写调整

调整:增加一个关闭按钮,弹出窗口大小。

在WBAuthorizeWebView.m文件的方法:bounceOutAnimationStopped里添加按钮:

 

 

[cpp]  view plain copy
  1. UIButton *closeButton [UIButton buttonWithType:UIButtonTypeCustom];  
  2.     [closeButton setFrame:CGRectMake(280, 430, 60, 60)];  
  3.     [closeButton setImageEdgeInsets:UIEdgeInsetsMake(3, 0, 0, 0)];  
  4.     [closeButton setImage:[UIImage imageNamed:@"close"forState:UIControlStateNormal];  
  5.       
  6.     [closeButton addTarget:self action:@selector(hideAndCleanUp) forControlEvents:UIControlEventTouchUpInside];  
  7.     [self addSubview:closeButton];  

close.png图片sdk里自带就有。hideAndCleanUp方法就是把窗口移除。hideAndCleanUp方法原来就有。运行效果:

 


看右下角有个关闭按钮,为什么放在右下角呢,因为右上角有个注册按钮,容易被点到。一会把网页窗口最大化了就能看到了。

扩大窗口

 

在WBAuthorizeWebView.m文件的方法- (void)sizeToFitOrientation:(UIInterfaceOrientation)orientation 修改如下:

上面的尺寸是横屏的时候的,我修改了竖屏时的窗口的大小。

 

[cpp]  view plain copy
  1. (void)sizeToFitOrientation:(UIInterfaceOrientation)orientation  
  2.  
  3.     [self setTransform:CGAffineTransformIdentity];  
  4.       
  5.     if (UIInterfaceOrientationIsLandscape(orientation))  
  6.      
  7.         [self setFrame:CGRectMake(0, 0, 480, 320)];  
  8.         [panelView setFrame:CGRectMake(10, 30, 460, 280)];  
  9.         [containerView setFrame:CGRectMake(10, 10, 440, 260)];  
  10.         [webView setFrame:CGRectMake(0, 0, 440, 260)];  
  11.         [indicatorView setCenter:CGPointMake(240, 160)];  
  12.      
  13.     else  
  14.      
  15.         [self setFrame:CGRectMake(0, 5, 320, 470)];  
  16.         [panelView setFrame:CGRectMake(0, 5, 320, 470)];  
  17.         [containerView setFrame:CGRectMake(0, 5, 320, 460)];  
  18.         [webView setFrame:CGRectMake(0, 0, 320, 460)];  
  19.         [indicatorView setCenter:CGPointMake(160, 240)];  
  20.      
  21.       
  22.     [self setCenter:CGPointMake(160, 240)];  
  23.       
  24.     [self setTransform:[self transformForOrientation:orientation]];  
  25.       
  26.     previousOrientation orientation;  
  27.  

 

运行效果:


这个状态差不多就可以了。


还有在调用WeiBoEngine 的Logout 登出无效的情况。修改如下:

在WBAuthorize.m文件,把startAuthorize函数修改如下:

 

[cpp]  view plain copy
  1. NSDictionary *params [NSDictionary dictionaryWithObjectsAndKeys:appKey, @"client_id" 
  2.                                                                       @"code"@"response_type" 
  3.                                                                       redirectURI, @"redirect_uri"  
  4.                                                                       @"mobile"@"display" 
  5.                                                                       @"true",@"forcelogin"nil];  

就是在 params里添加@”true”,@”forcelogin”。

 

以上是使用新浪微博sdk开发遇到的问题和解决的一些方法。

修改过的项目代码:http://download.csdn.net/detail/totogo2010/4928029

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值