超級厲害獲取接口大全

就醬




AppDelegate.m


#import "ViewController.h"#import "findViewController.h"#import "myViewController.h"


//創(chuàng)建導航控制器和標簽控制器

?UINavigationController * vcNav=[[UINavigationController alloc]initWithRootViewController:[ViewController new]];

? ? vcNav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"報告" image:[UIImage imageNamed:@"消息灰.png"] selectedImage:[UIImage imageNamed:@"消息藍.png"]];


? ? UINavigationController * findNav=[[UINavigationController alloc]initWithRootViewController:[findViewController new]];


? ? findNav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"發(fā)現(xiàn)" image:[UIImage imageNamed:@"喜歡灰.png"] selectedImage:[UIImage imageNamed:@"喜歡藍.png"]];


? ? UINavigationController * myNav=[[UINavigationController alloc]initWithRootViewController:[myViewController new]];


? ? myNav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"我" image:[UIImage imageNamed:@"我的灰.png"] selectedImage:[UIImage imageNamed:@"我的藍.png"]];


? ? UITabBarController * tbc=[[UITabBarController alloc]init];

? ? tbc.viewControllers=@[vcNav,findNav,myNav];

? ? self.window.rootViewController=tbc;



findViewController.m


#define FenLei @"enumeration/list?type=StrategyType"?

#define GongGong @"http://124.65.238.30:3300/bingyun/api/"?

#define XiangDui @"strategy/page?pageNo=1&pageSize=10&strategyType=POSTURE"?

?#import "myTableViewCell.h"?

#import "AFNetworking.h"

?#import "UIImageView+WebCache.h"?

#import "MJExtension.h"

?#import "FeiLeiModel.h"?

#import "SuDuModel.h"



@property(nonatomic,strong)UISegmentedControl * segment;?

@property(nonatomic,strong)UITableView * tbv;?

@property(nonatomic,strong)NSMutableArray * dataArr;?

@property(nonatomic,strong)NSMutableArray * feileiArr;?

@property(nonatomic,strong)UIButton * btn;?

@property(nonatomic,strong)UIButton * twoBtn;?

@property(nonatomic,strong)UIButton * threeBtn;?

@property(nonatomic,strong)UIButton * fourBtn;

還有表格協(xié)議


//初始化分段控制器

-(UISegmentedControl * )segment

{

? ? if(!_segment)

? ? {

? ? ? ? //設置分段控制器的內容

? ? ? ? _segment=[[UISegmentedControl alloc]initWithItems:@[@"攻略",@"訓練營",@"資訊"]];


? ? ? ? //設置分段控制器的位置

? ? ? ? _segment.frame=CGRectMake(20,0,self.view.frame.size.width-40,40);


? ? ? ? [_segment addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];


? ? }

? ? return _segment;

}

//初始化表格

-(UITableView * )tbv

{

? ? if(!_tbv)

? ? {

? ? ? ? _tbv=[[UITableView alloc]initWithFrame:CGRectMake(3, 100, self.view.frame.size.width-6, self.view.frame.size.height-80) style:UITableViewStylePlain];


? ? ? ? _tbv.delegate=self;


? ? ? ? _tbv.dataSource=self;


? ? }

? ? return _tbv;

}


- (void)viewDidLoad


//設置導航不透明

? ? self.navigationController.navigationBar.translucent=NO;


? ? //設置主視圖背景顏色

? ? self.view.backgroundColor=[UIColor whiteColor];


? ? //設置分段控制器的位置,添加到導航條

? ? self.navigationItem.titleView=self.segment;


? ? //初始化數(shù)組

? ? self.dataArr=[NSMutableArray new];


? ? self.feileiArr=[NSMutableArray new];




-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

?{? ?

?return self.dataArr.count;?

}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath


{

staticNSString* string=@"string";


? ? myTableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:string];


? ? if(!cell)

? ? {

? ? ? ? cell=[[myTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:string];

? ? }

? ? SuDuModel* sd=self.dataArr[indexPath.row];


? ? [cell.imgvsd_setImageWithURL:[NSURLURLWithString:sd.photo]];


? ? cell.zhu.text=sd.title;


? ? cell.fu.text=sd.suitIntro;


? ? cell.look.text=sd.readNum;


? ? UILabel * label=[[UILabel alloc]initWithFrame:CGRectMake(340, 115, 50, 40)];

? ? label.text=@"??";


? ? [celladdSubview:label];

? ? returncell;

}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath?

{? ?

?return 170;

?}


//實現(xiàn)分段控制器的方法

-(void)change:(UISegmentedControl* )sender

{

? ? if(sender.selectedSegmentIndex==0)

? ? {

? ? ? ? NSLog(@"1");

? ? ? ? //設置全部攻略的label

? ? ? ? UILabel* label=[[UILabelalloc]initWithFrame:CGRectMake(3,10,150,40)];

? ? ? ? label.text=@"全部攻略";


? ? ? ? label.font=[UIFontsystemFontOfSize:20];


? ? ? ? [self.viewaddSubview:label];


?//拼接字符串網(wǎng)址

? ? ? ? NSString* onestring=[NSStringstringWithFormat:@"%@%@",GongGong,FenLei];


? ? ? ? AFHTTPSessionManager * manager=[AFHTTPSessionManager manager];


? ? ? ? [managerGET:onestringparameters:nilsuccess:^(NSURLSessionDataTask*task,idresponseObject) {

? ? ? ? ? ? NSLog(@"--------%@",responseObject);


?//打印totalProperty判斷分類按鈕的數(shù)量

? ? ? ? ? ? idshuliang=responseObject[@"totalProperty"];

? ? ? ? ? ? NSLog(@"+++++++++%@",shuliang);


//獲取data里面的元素

? ? ? ? ? ? NSArray* arr=responseObject[@"data"];


? ? ? ? ? ? //遍歷

? ? ? ? ? ? for(NSDictionary* dicinarr) {

? ? ? ? ? ? ? ? FeiLeiModel* feilei=[FeiLeiModelmj_objectWithKeyValues:dic];



? ? ? ? ? ? ? ? [self.feileiArraddObject:feilei];

? ? ? ? ? ? }

? ? ? ? }failure:^(NSURLSessionDataTask*task,NSError*error) {

? ? ? ? ? ? NSLog(@"error=%@",error);

? ? ? ? }];

? ? ? ? NSLog(@"\\\\\\\\\\\\\\\\%@",self.feileiArr);




?//數(shù)量為4箕昭,根據(jù)內容創(chuàng)建四個按鈕? ? ? ?

?//初始化速度按鈕

? ? ? ? self.btn=[[UIButtonalloc]initWithFrame:CGRectMake(2,60,self.view.frame.size.width/4-6,40)];


? ? ? ? [self.btn addTarget:self action:@selector(sudu) forControlEvents:UIControlEventTouchUpInside];


? ? ? ? [self.btn setTitle:@"速度" forState:UIControlStateNormal];


? ? ? ? [self.btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];


? ? ? ? self.btn.backgroundColor=[UIColor lightGrayColor];


? ? ? ? self.btn.layer.masksToBounds=YES;


? ? ? ? self.btn.layer.cornerRadius=20;


? ? ? ? [self.viewaddSubview:self.btn];



? ? ? ? //初始化技巧按鈕

? ? ? ? self.twoBtn=[[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width/4, 60, self.view.frame.size.width/4-6, 40)];


? ? ? ? [self.twoBtn setTitle:@"技巧" forState:UIControlStateNormal];


?? ? ? ? [self.twoBtn addTarget:self action:@selector(jiqiao) forControlEvents:UIControlEventTouchUpInside];


? ? ? ? [self.twoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];


? ? ? ? self.twoBtn.backgroundColor=[UIColor lightGrayColor];


? ? ? ? self.twoBtn.layer.masksToBounds=YES;


? ? ? ? self.twoBtn.layer.cornerRadius=20;


? ? ? ? [self.viewaddSubview:self.twoBtn];



? ? ? ? //初始化姿勢按鈕

? ? ? ? self.threeBtn=[[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width/4*2, 60, self.view.frame.size.width/4-6, 40)];


? ? ? ? [self.threeBtn setTitle:@"姿勢" forState:UIControlStateNormal];


?? ? ? ? [self.threeBtn addTarget:self action:@selector(zishi) forControlEvents:UIControlEventTouchUpInside];


? ? ? ? [self.threeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];


? ? ? ? self.threeBtn.backgroundColor=[UIColor lightGrayColor];


? ? ? ? self.threeBtn.layer.masksToBounds=YES;


? ? ? ? self.threeBtn.layer.cornerRadius=20;


? ? ? ? [self.viewaddSubview:self.threeBtn];



? ? ? ? //初始化進球按鈕

? ? ? ? self.fourBtn=[[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width/4*3, 60, self.view.frame.size.width/4-6, 40)];


? ? ? ? [self.fourBtn setTitle:@"進球" forState:UIControlStateNormal];


?? ? ? ? [self.fourBtn addTarget:self action:@selector(jinqiu) forControlEvents:UIControlEventTouchUpInside];


? ? ? ? [self.fourBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];


? ? ? ? self.fourBtn.backgroundColor=[UIColor lightGrayColor];


? ? ? ? self.fourBtn.layer.masksToBounds=YES;


? ? ? ? self.fourBtn.layer.cornerRadius=20;


? ? ? ? [self.viewaddSubview:self.fourBtn];


? ? }

? ? else if(sender.selectedSegmentIndex==1)

? ? {

? ? ? ? NSLog(@"2");


? ? ? ? UIView * view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];


? ? ? ? view.backgroundColor=[UIColor whiteColor];


? ? ? ? [self.viewaddSubview:view];

? ? }

? ? else if(sender.selectedSegmentIndex==2)

? ? {

? ? ? ? NSLog(@"3");


? ? ? ? UIView* oneview=[[UIViewalloc]initWithFrame:self.view.frame];


? ? ? ? oneview.backgroundColor=[UIColor whiteColor];


? ? ? ? [self.viewaddSubview:oneview];

? ? }

}



//實現(xiàn)速度按鈕的點擊方法

-(void)sudu

{

? ? self.btn.backgroundColor=[UIColor blueColor];

? ? self.twoBtn.backgroundColor=[UIColor lightGrayColor];

? ? self.threeBtn.backgroundColor=[UIColor lightGrayColor];

? ? self.fourBtn.backgroundColor=[UIColor lightGrayColor];



? ? //添加表格到主視圖

? ? [self.viewaddSubview:self.tbv];



? ? //拼接網(wǎng)址字符串

? ? NSString* string=[NSStringstringWithFormat:@"%@%@",GongGong,XiangDui];


? ? //封裝請求參數(shù)為字典

? ? NSDictionary * dic=@{@"strategyType":@"攻略分類"};


? ? AFHTTPSessionManager * manager=[AFHTTPSessionManager manager];


? ? [managerGET:stringparameters:dicsuccess:^(NSURLSessionDataTask*task,idresponseObject) {

? ? ? ? NSLog(@"00000000000000%@",responseObject);


? ? ? ? NSArray* arr=responseObject[@"data"];


? ? ? ? for(NSDictionary* dicinarr) {

? ? ? ? ? ? SuDuModel* sudu=[SuDuModelmj_objectWithKeyValues:dic];


? ? ? ? ? ? [self.dataArraddObject:sudu];

? ? ? ? }


? ? ? ? dispatch_async(dispatch_get_main_queue(), ^{

?? ? ? ? ? ? [self.tbvreloadData];

? ? ? ? });


? ? }failure:^(NSURLSessionDataTask *task, NSError *error) {

? ? ? ? NSLog(@"%@",error);

? ? }];



}

//實現(xiàn)技巧按鈕的點擊方法

-(void)jiqiao

{

? ? self.btn.backgroundColor=[UIColor lightGrayColor];

? ? self.twoBtn.backgroundColor=[UIColor blueColor];

? ? self.threeBtn.backgroundColor=[UIColor lightGrayColor];

? ? self.fourBtn.backgroundColor=[UIColor lightGrayColor];


? ? UIView * view=[[UIView alloc]initWithFrame:CGRectMake(3, 100, self.view.frame.size.width-6, self.view.frame.size.height-80)];


? ? view.backgroundColor=[UIColor whiteColor];


? ? [self.viewaddSubview:view];


}

//實現(xiàn)姿勢按鈕的點擊方法

-(void)zishi

{

? ? self.btn.backgroundColor=[UIColor lightGrayColor];

? ? self.twoBtn.backgroundColor=[UIColor lightGrayColor];

? ? self.threeBtn.backgroundColor=[UIColor blueColor];

? ? self.fourBtn.backgroundColor=[UIColor lightGrayColor];


? ? UIView * view=[[UIView alloc]initWithFrame:CGRectMake(3, 100, self.view.frame.size.width-6, self.view.frame.size.height-80)];


? ? view.backgroundColor=[UIColor whiteColor];


? ? [self.viewaddSubview:view];

}

//實現(xiàn)進球按鈕的點擊方法

-(void)jinqiu

{

? ? self.btn.backgroundColor=[UIColor lightGrayColor];

? ? self.twoBtn.backgroundColor=[UIColor lightGrayColor];

? ? self.threeBtn.backgroundColor=[UIColor lightGrayColor];

? ? self.fourBtn.backgroundColor=[UIColor blueColor];


? ? UIView * view=[[UIView alloc]initWithFrame:CGRectMake(3, 100, self.view.frame.size.width-6, self.view.frame.size.height-80)];


? ? view.backgroundColor=[UIColor whiteColor];


? ? [self.viewaddSubview:view];


}


那兩個控制器隨便給倆顏色








myTableViewCell.h


@property(nonatomic,strong)UIImageView * imgv;

@property(nonatomic,strong)UILabel * zhu;

@property(nonatomic,strong)UILabel * fu;

@property(nonatomic,strong)UILabel * look;



myTableViewCell.m


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier

{

? ? if(self=[superinitWithStyle:stylereuseIdentifier:reuseIdentifier])

? ? {

? ? ? ? [selfaddSubview:self.imgv];

? ? ? ? [selfaddSubview:self.zhu];

? ? ? ? [selfaddSubview:self.fu];

? ? ? ? [selfaddSubview:self.look];

? ? }

? ? return self;

}

-(UIImageView * )imgv

{

? ? if(!_imgv)

? ? {

? ? ? ? _imgv=[[UIImageView alloc]initWithFrame:CGRectMake(3, 10, 200, 150)];


? ? }

? ? return _imgv;

}

-(UILabel* )zhu

{

? ? if(!_zhu)

? ? {

? ? _zhu=[[UILabel alloc]initWithFrame:CGRectMake(210, 10, 210, 40)];

? ? ? ? _zhu.font=[UIFont systemFontOfSize:20];

? ? }

? ? return _zhu;

}

-(UILabel* )fu

{

? ? if(!_fu)

? ? {

? ? ? ? _fu=[[UILabel alloc]initWithFrame:CGRectMake(210, 60, 210, 40)];

? ? ? ? _fu.font=[UIFont systemFontOfSize:16];

? ? ? ? _fu.textColor=[UIColor lightGrayColor];

? ? ? ? _fu.numberOfLines=0;


? ? }

? ? return _fu;

}

-(UILabel* )look

{

? ? if(!_look)

? ? {

? ? ? ? _look=[[UILabel alloc]initWithFrame:CGRectMake(350, 120, 50, 30)];


? ? ? ? _look.textColor=[UIColor lightGrayColor];


? ? ? ? _look.textAlignment=NSTextAlignmentRight;

? ? }

? ? return _look;

}







FeiLeiModel.h


@property(nonatomic,strong)NSString * text;


SuDuModel.h


@property(nonatomic,strong)NSString * title;

@property(nonatomic,strong)NSString * suitIntro;

@property(nonatomic,strong)NSString * readNum;

@property(nonatomic,strong)NSString * photo;



開網(wǎng)


ojbk

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末揽思,一起剝皮案震驚了整個濱河市爪膊,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌顾瞻,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,042評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異遥倦,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,996評論 2 384
  • 文/潘曉璐 我一進店門袒哥,熙熙樓的掌柜王于貴愁眉苦臉地迎上來缩筛,“玉大人,你說我怎么就攤上這事堡称∠古祝” “怎么了?”我有些...
    開封第一講書人閱讀 156,674評論 0 345
  • 文/不壞的土叔 我叫張陵却紧,是天一觀的道長桐臊。 經常有香客問我,道長晓殊,這世上最難降的妖魔是什么断凶? 我笑而不...
    開封第一講書人閱讀 56,340評論 1 283
  • 正文 為了忘掉前任,我火速辦了婚禮巫俺,結果婚禮上认烁,老公的妹妹穿的比我還像新娘。我一直安慰自己识藤,他們只是感情好砚著,可當我...
    茶點故事閱讀 65,404評論 5 384
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著痴昧,像睡著了一般稽穆。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上赶撰,一...
    開封第一講書人閱讀 49,749評論 1 289
  • 那天舌镶,我揣著相機與錄音,去河邊找鬼豪娜。 笑死餐胀,一個胖子當著我的面吹牛,可吹牛的內容都是我干的瘤载。 我是一名探鬼主播否灾,決...
    沈念sama閱讀 38,902評論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼鸣奔!你這毒婦竟也來了墨技?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 37,662評論 0 266
  • 序言:老撾萬榮一對情侶失蹤挎狸,失蹤者是張志新(化名)和其女友劉穎扣汪,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體锨匆,經...
    沈念sama閱讀 44,110評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡崭别,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 36,451評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片茅主。...
    茶點故事閱讀 38,577評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡舞痰,死狀恐怖,靈堂內的尸體忽然破棺而出暗膜,到底是詐尸還是另有隱情匀奏,我是刑警寧澤,帶...
    沈念sama閱讀 34,258評論 4 328
  • 正文 年R本政府宣布学搜,位于F島的核電站娃善,受9級特大地震影響,放射性物質發(fā)生泄漏瑞佩。R本人自食惡果不足惜聚磺,卻給世界環(huán)境...
    茶點故事閱讀 39,848評論 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望炬丸。 院中可真熱鬧瘫寝,春花似錦、人聲如沸稠炬。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,726評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽首启。三九已至暮屡,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間毅桃,已是汗流浹背褒纲。 一陣腳步聲響...
    開封第一講書人閱讀 31,952評論 1 264
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留钥飞,地道東北人莺掠。 一個月前我還...
    沈念sama閱讀 46,271評論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像读宙,于是被迫代替她去往敵國和親彻秆。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 43,452評論 2 348

推薦閱讀更多精彩內容