码农福利,自定义微博小尾巴,闪瞎他们的双眼

自从王思聪发布了那条小尾巴是iphone6的微博之后,引起了无数人的跟风,大家争先恐后的把自己的小尾巴改成iphone6。但是好景不长,新浪就把这个方法给和谐了。

被“无情”和谐掉的小尾巴是通过“网页发布窗”来实现的,可手动设置app_url(也就是每个型号手机对应的key),用这种方法可以自行修改微博的小尾巴。而本文我来分享下基于iOS平台APP实现自定义修改微博小尾巴。

微博小尾巴1微博小尾巴2微博小尾巴3微博小尾巴4微博小尾巴5

建议先下载源码点击此处下载

注:此源码是基于iOS的,但实现方法、相应接口和数据都是通用的,接口是新浪的,但是什么时候会被和谐掉,这个小编可不敢说,总之可以先用着。

源码内容包括~

*微博接口分析

* UITableView + UISearchBar 使用

*UITableView分级菜单

*有米广告嵌入

微博接口分析~

微博尾巴可以分为两大类:手机型号和应用名称。

手机型号:我们正常发微博的时候,如果是手机,会根据设备信息,自动显示对应尾巴。新浪会为每个设备分配一个app_url,这个是唯一的。

应用名称:每一个在微博开放平台注册过的应用都有独立的分享链接,会带上对应的尾巴。而区分各个应用的就是对应的appKey。

1、获取各个手机型号的app_url

小编这是罗列了几个比较常用的(当然不能少了iphone的了,装逼必备嘛~),文件格式是.plist. iOS便可以直接打开,但是其他系统上,需要自己去读,它的格式是XML。

获取方法:A、百度收集B、右键微博,查看链接

获取各个手机型号的app_url

2、手机型号调用方法

之前使用过调用发布窗,但是已经被和谐掉了,本次尝试“话题窗”,自定义尾巴。这样,使用《微博小尾巴》这个应用的所有人发的微博,都会在这里显示,也是比较方便的。

调用方法如下:

1 webView.webStr = [NSString stringWithFormat:@"http://widget.weibo.com/topics/topic_vote_base.php?tag=来自微博小尾巴
2&isshowright=0&language=zh_cn&dup=1&antispam=1&isOutTopicSearch=2&border=0&version=base&footbar=0&app_src=%@", appKey];

这里的webStr 是一个NSStirng字符串,用来保存对应的URL。 appKey根据选择的手机型号, 从plist中获取。webStr传入后, 继续调用显示。

1webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, 320, Screen_height-64)];  
2request =[NSURLRequest requestWithURL:[NSURL URLWithString:[webStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];  
3[webView setDelegate:self];  
4[self.view addSubview: webView];  
5[webView loadRequest:request];

这样便可以通过网页形式发布微博,然后显示你喜欢的小尾巴了~是不是很简单~

3、应用appKey获取和使用

获取方法:

进入微博应用广场----> 选择某个应用----->显示页面源码------>搜索appKey。

获取方法

调用方法:

1 webView.webStr = [NSString stringWithFormat:@"http://v.t.sina.com.cn/share/share.php?appkey=%@&;content=utf8", appKey];

UITableView + UISearchBar 使用~

01//添加列表  
02     myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 104, 320, Screen_height - 154)];  
03     myTableView.delegate = self;  
04     myTableView.dataSource = self;  
05     //背景颜色  
06     myTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"eyeBackground.jpg"]];  
07     [self.view addSubview:myTableView];  
08        
09     //初始化搜索列表bar  
10     filteredArr = [[NSMutableArray alloc]init];  
11     searchBarReagion = [[UISearchBar alloc] initWithFrame:CGRectMake(0,64,320,44)];  
12     searchBarReagion.placeholder = @"搜索";  
13     searchBarReagion.delegate = self;  
14     [self.view addSubview:searchBarReagion];
01#pragma mark  
02#pragma mark SearchBar Delegate  
03    
04 - (void) searchBarTextDidBeginEditing: (UISearchBar*) searchBar  
05{  
06        
07     [searchBarReagion setShowsCancelButton: YES animated: YES];  
08}  
09    
10 - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText  
11{  
12        
13     isSearchActiveDM = TRUE;  
14     [filteredArr removeAllObjects];  
15        
16     for (int i=0; i0)  
17         {  
18                
19             [filteredArr addObject:countryDictinary];  
20         }  
21            
22     }  
23        
24     [myTableView reloadData];  
25}  
26    
27 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar  
28{  
29     [searchBarReagion resignFirstResponder];  
30     [searchBarReagion setShowsCancelButton: NO animated: YES];  
31}  
32    
33 - (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar  
34{  
35        
36     isSearchActiveDM = FALSE;  
37     searchBarReagion.text = @"";  
38     [searchBarReagion setShowsCancelButton: NO animated: YES];  
39     [searchBarReagion resignFirstResponder];  
40        
41     [myTableView reloadData];  
42}
1- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  
2{  
3     if (isSearchActiveDM)  
4     {  
5         return [filteredArr count];  
6     }  
7     return [resultArr count];  
8}

通过以上代码可以发现,UITableView 和 UISearchBar 是没有直接联系的,都实现自己的方法。只是在搜索框输入内容后,标记为 isSearchActiveDM,然后在UITableView实现的各个方法中, 通过判断是否处于isSearchActiveDM, 来显示不同的数据,从而达到动态搜索的效果。

UITableView分级菜单~

小编在code4app发现一个不错的DEMO并将其整合到了应用中,源文件在NavigationStackResource文件夹中,调用方法如下:

01//Initialize the controller data  
02 NSString* plistPath = [[NSBundle mainBundle] pathForResource: @"NavStackControllerData"  
03                                                       ofType: @"plist"];  
04// Build the array from the plist  
05self.jsonDictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];  
06    
07//customizing..  
08 [self setHeaderLabelFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:20.0f]];  
09[self setHeaderLabelColor:[UIColor blackColor]];  
10[self setHeaderBackGroundColor:[UIColor whiteColor]];  
11    
12 [self setSelectedHeaderLabelFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0f]];  
13[self setSelectedHeaderLabelColor:[UIColor blackColor]];  
14[self setSelectedHeaderBackGroundColor:[UIColor whiteColor]];  
15    
16[self setHeaderSeparatorColor:[UIColor lightGrayColor]];

选择各个cell响应方法:

1 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  
2{  
3     appKey = [[[[self.jsonDictionary objectForKey:self.clickedCountryName]objectForKey:@"subheadingArr"]objectAtIndex:indexPath.row]objectForKey:@"subheadingKey"];  
4     appName = [[[[self.jsonDictionary objectForKey:self.clickedCountryName]objectForKey:@"subheadingArr"]objectAtIndex:indexPath.row]objectForKey:@"subheadingName"];  
5        
6     [self performSegueWithIdentifier:@"phonePushToWeb" sender:self];  
7}

有米广告的植入~

1、注册应用,申请id

可登录有米官网注册一个开发者账号,获取发布id和应用密钥。

注:一个appid只能对应一个bundle id。

2、下载YouMiSDK iOS压缩包

下载的压缩包,包含以下几个文件:

下载的压缩包

doc文件夹中的doc.html为中文教程,doc_en.html是英文教程。

lib文件夹就是要添加到你的工程的文件夹,里面包含了libYouMi.a静态文件和头文件。

samples文件夹YouMiSDK的程序例子。

3、往工程导入头文件,静态库文件

积分墙必须的头文件为

YouMiConfig.h

YouMiWall.h

YouMiWallAppModel.h

YouMiPointsManager.h (用于查询积分)

静态库文件为

libYouMi.a

4、为工程添加系统自带的Frameworks

Security.framework

SystemConfiguration.framework

CFNetwork.framework

QuartzCore.framework

libsqlite3.dylib

StoreKit.framework 这个framework要改为Optional,其他都为Required

5、到AppDelegate.m文件中初始化YouMiSDK

(1)在AppDelegate.m文件中添加以下语句

1#import "YouMiConfig.h"

(2)在AppDelegate.m自动生成的

1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

的函数中添加以下代码:

1 [YouMiConfig setUserID:id_you_define]; // [可选] 例如开发者的应用是有登录功能的,则可以使用登录后的用户账号来替代有米为每台机器提供的标识(有米会为每台设备生成的唯一标识符)。
2 [YouMiConfig setUseInAppStore:YES];  // [可选]开启内置appStore,详细请看YouMiSDK常见问题解答
3 [YouMiConfig launchWithAppID:@"[Your AppID]" appSecret:@"[Your AppSecret]"];

注1:替换“Your AppID”和“Your AppSecret“为你的appid和appSecret。

注2:本文档的代码片段在SDK相应的头文件中都有比较详细的介绍,对于本文档的代码有什么疑问,可查看头文件。

(3)设置显示全屏广告(如积分墙)的全屏UIWindow(此处可选,推荐设置)

对于使用UIKit编写的APP可以在application:didFinishLaunchingWithOptions:中的[self.window makeKeyAndVisible]之后设置:

1[self.window makeKeyAndVisible];
2// 设置显示全屏广告的window   
3[YouMiConfig setFullScreenWindow:self.window];

这里,小编只是说明了简单的广告条。

调用广告条~

在需要用到广告条的地方创建广告条并添加

01

// 创建广告条

02adView = [[YouMiView alloc] initWithContentSizeIdentifier:YouMiBannerContentSizeIdentifier320x50 delegate:nil];
03 
04//可以设置委托[可选]
05adView.delegate = self;
06//设置文字广告的属性[可选]
07adView.indicateTranslucency = YES;
08adView.indicateRounded = NO;
09//添加对应的关键词 [可选]
10 [adView addKeyword:@"女性"];
11 
12// 开始请求广告
13[adView start];
14 
15// 把广告条添加到特定的view中 [例如]
16[self.view addSubview:adView];

基于iOS平台的app自定义微博小尾巴就讲解到此,想不想土豪一把?想不想让受人膜拜?想的话就自己动手试试吧,让你的微博小尾巴闪亮亮!!!

转载于:https://www.cnblogs.com/Demon614/p/3992289.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值