日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

IOS开发之UI基础LOL英雄展示-15

發(fā)布時間:2023/12/18 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 IOS开发之UI基础LOL英雄展示-15 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

IOS開發(fā)之UI基礎(chǔ)LOL英雄展示-15

// // ViewController.m // 15-英雄展示-單組數(shù)據(jù) // // Created by 魯軍 on 2021/2/3. //#import "ViewController.h" #import "CZHero.h" @interface ViewController ()<UITableViewDataSource,UITableViewDelegate>@property(nonatomic,strong)NSArray *heros;@property (weak, nonatomic) IBOutlet UITableView *tableView;@end@implementation ViewController- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{//NSLog(@"%ld",(long) indexPath.row);CZHero *hero = self.heros[indexPath.row];UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"標(biāo)題" message:@"這是一些信息" preferredStyle:UIAlertControllerStyleAlert];}//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ // // int rowNum = indexPath.row; // if(rowNum%2==0){ // // return 60; // }else{ // return 60; // } // //}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{CZHero *model =self.heros[indexPath.row];// UITableViewCell *cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];// 單元格重復(fù)使用//在創(chuàng)建單元格的時候指定一個重用ID// 當(dāng)需要一個新的單元格的時候,先去緩存池中找static NSString *ID = @"hero_cell";UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];if(cell==nil){cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];}cell.imageView.image=[UIImage imageNamed:model.icon];cell.textLabel.text=model.name;cell.detailTextLabel.text=model.intro;cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;NSLog(@"%p----行索引 = %ld",cell,(long)indexPath.row);// cell.accessoryView =[[UISwitch alloc] init]; // if(indexPath.row%2==0) // { // cell.backgroundColor=[UIColor yellowColor]; // }else{ // // cell.backgroundColor=[UIColor blueColor]; // } // UIView *bgView = [[UIView alloc] init]; // bgView.backgroundColor = [UIColor greenColor]; // // cell.selectedBackgroundView =bgView;return cell; }- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return self.heros.count; }// //- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ // return 1; //}- (NSArray *)heros{if(_heros==nil){NSString *path = [[NSBundle mainBundle] pathForResource:@"heros.plist" ofType:nil];NSArray *arrayDict=[NSArray arrayWithContentsOfFile:path];NSMutableArray *arrayModels = [NSMutableArray array];for(NSDictionary *dict in arrayDict){CZHero *model = [CZHero heroWithDict:dict];[arrayModels addObject:model];}_heros = arrayModels;}return _heros;}- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.// self.tableView.rowHeight=80;// self.tableView.separatorColor=[UIColor redColor];//self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;self.tableView.tableHeaderView=[UIButton buttonWithType:UIButtonTypeContactAdd];self.tableView.tableFooterView=[[UISwitch alloc] init];}@end // // CZHero.h // 15-英雄展示-單組數(shù)據(jù) // // Created by 魯軍 on 2021/2/3. //#import <Foundation/Foundation.h>NS_ASSUME_NONNULL_BEGIN@interface CZHero : NSObject@property(nonatomic,copy)NSString *icon; @property(nonatomic,copy)NSString *intro; @property(nonatomic,copy)NSString *name;-(instancetype)initWithDict:(NSDictionary *)dict; +(instancetype)heroWithDict:(NSDictionary *)dict;@endNS_ASSUME_NONNULL_END // // CZHero.m // 15-英雄展示-單組數(shù)據(jù) // // Created by 魯軍 on 2021/2/3. //#import "CZHero.h"@implementation CZHero-(instancetype)initWithDict:(NSDictionary *)dict{if(self== [super init]){[self setValuesForKeysWithDictionary:dict];}return self; } +(instancetype)heroWithDict:(NSDictionary *)dict{return [[self alloc] initWithDict:dict]; }@end

總結(jié)

以上是生活随笔為你收集整理的IOS开发之UI基础LOL英雄展示-15的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。