iOS開發(fā)中使用UIScrollView實(shí)現(xiàn)圖片輪播和點(diǎn)擊加載
UIScrollView控件實(shí)現(xiàn)圖片輪播
一、實(shí)現(xiàn)效果
實(shí)現(xiàn)圖片的自動(dòng)輪播
二、實(shí)現(xiàn)代碼
storyboard中布局
代碼:
#import "YYViewController.h"
@interface YYViewController () <UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
/**
* 頁(yè)碼
*/
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
@property (nonatomic, strong) NSTimer *timer;
@end
@implementation YYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// 圖片的寬
CGFloat imageW = self.scrollview.frame.size.width;
// CGFloat imageW = 300;
// 圖片高
CGFloat imageH = self.scrollview.frame.size.height;
// 圖片的Y
CGFloat imageY = 0;
// 圖片中數(shù)
NSInteger totalCount = 5;
// 1.添加5張圖片
for (int i = 0; i < totalCount; i++) {
UIImageView *imageView = [[UIImageView alloc] init];
// 圖片X
CGFloat imageX = i * imageW;
// 設(shè)置frame
imageView.frame = CGRectMake(imageX, imageY, imageW, imageH);
// 設(shè)置圖片
NSString *name = [NSString stringWithFormat:@"img_0%d", i + 1];
imageView.image = [UIImage imageNamed:name];
// 隱藏指示條
self.scrollview.showsHorizontalScrollIndicator = NO;
[self.scrollview addSubview:imageView];
}
// 2.設(shè)置scrollview的滾動(dòng)范圍
CGFloat contentW = totalCount *imageW;
//不允許在垂直方向上進(jìn)行滾動(dòng)
self.scrollview.contentSize = CGSizeMake(contentW, 0);
// 3.設(shè)置分頁(yè)
self.scrollview.pagingEnabled = YES;
// 4.監(jiān)聽scrollview的滾動(dòng)
self.scrollview.delegate = self;
[self addTimer];
}
- (void)nextImage
{
int page = (int)self.pageControl.currentPage;
if (page == 4) {
page = 0;
}else
{
page++;
}
// 滾動(dòng)scrollview
CGFloat x = page * self.scrollview.frame.size.width;
self.scrollview.contentOffset = CGPointMake(x, 0);
}
// scrollview滾動(dòng)的時(shí)候調(diào)用
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@"滾動(dòng)中");
// 計(jì)算頁(yè)碼
// 頁(yè)碼 = (contentoffset.x + scrollView一半寬度)/scrollView寬度
CGFloat scrollviewW = scrollView.frame.size.width;
CGFloat x = scrollView.contentOffset.x;
int page = (x + scrollviewW / 2) / scrollviewW;
self.pageControl.currentPage = page;
}
// 開始拖拽的時(shí)候調(diào)用
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
// 關(guān)閉定時(shí)器(注意點(diǎn); 定時(shí)器一旦被關(guān)閉,無(wú)法再開啟)
// [self.timer invalidate];
[self removeTimer];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
// 開啟定時(shí)器
[self addTimer];
}
/**
* 開啟定時(shí)器
*/
- (void)addTimer{
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(nextImage) userInfo:nil repeats:YES];
106 }
/**
* 關(guān)閉定時(shí)器
*/
- (void)removeTimer
{
[self.timer invalidate];
}
@end
提示:以下兩個(gè)屬性已經(jīng)和storyboard中的控件進(jìn)行了連線。
@property (weak, nonatomic) IBOutletUIScrollView *scrollview;
@property (weak, nonatomic) IBOutletUIPageControl *pageControl;
補(bǔ)充:定時(shí)器NSTimer
定時(shí)器 適合用來(lái)隔一段時(shí)間做一些間隔比較長(zhǎng)的操作
NSTimeInterval:多長(zhǎng)多件操作一次
target :操作誰(shuí)
selector : 要操作的方法
userInfo: 傳遞參數(shù)
repeats: 是否重復(fù)
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(nextImage) userInfo:nil repeats:YES];
在UItableview中實(shí)現(xiàn)加載更多功能
一、實(shí)現(xiàn)效果
點(diǎn)擊加載更多按鈕,出現(xiàn)一個(gè)加載圖示,三秒鐘后添加兩條新的數(shù)據(jù)。
二、實(shí)現(xiàn)代碼和說明
當(dāng)在頁(yè)面(視圖部分)點(diǎn)擊加載更多按鈕的時(shí)候,主頁(yè)面(主控制器)會(huì)加載兩條數(shù)據(jù)進(jìn)來(lái)。
視圖部分的按鈕被點(diǎn)擊的時(shí)候,要讓主控制器加載數(shù)據(jù),刷新表格,2B青年會(huì)在視圖中增加一個(gè)主控制器的屬性,通過這個(gè)屬性去調(diào)用進(jìn)行加載,但在開發(fā)中通常通過代理模式來(lái)完成這個(gè)操作。
下面分別是兩種實(shí)現(xiàn)的代碼。
1、項(xiàng)目結(jié)構(gòu)和說明
說明:加載更多永遠(yuǎn)都放在這個(gè)tableview的最下端,因此這里設(shè)置成了這個(gè)tableview的tableFooterView。
self.tableview.tableFooterView=footerview;
在實(shí)現(xiàn)上通過xib來(lái)進(jìn)行處理,考慮到左右的留白,以及點(diǎn)擊后的要切換到加載按鈕和文字,要同時(shí)控制圖標(biāo)和文字,因此把加載圖標(biāo)和文字提示放在了一個(gè)view中以便控制,這個(gè)xib已經(jīng)和YYfooterview.xib進(jìn)行了關(guān)聯(lián),通過這個(gè)類來(lái)控制xib。
2、實(shí)現(xiàn)代碼
(1).垃圾代碼
數(shù)據(jù)模型部分
YYtg.h文件
//
// YYtg.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Global.h"
@interface YYtgModel : NSObject
@property(nonatomic,copy)NSString *icon;
@property(nonatomic,copy)NSString *buyCount;
@property(nonatomic,copy)NSString *title;
@property(nonatomic,copy)NSString *price;
//對(duì)外接口
YYinitH(tg)
@end
YYtg.m文件
//
// YYtg.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYtgModel.h"
@implementation YYtgModel
YYinitM(tg)
@end
注意:對(duì)于數(shù)據(jù)轉(zhuǎn)模型部分的構(gòu)造方法接口和實(shí)現(xiàn)代碼已經(jīng)通過自定義帶參數(shù)的宏來(lái)進(jìn)行了封裝。
封裝代碼如下:
#ifndef _0____________Global_h
#define _0____________Global_h
/**
* 自定義帶參數(shù)的宏
*/
#define YYinitH(name) -(instancetype)initWithDict:(NSDictionary *)dict;\
+(instancetype)name##WithDict:(NSDictionary *)dict;
#define YYinitM(name) -(instancetype)initWithDict:(NSDictionary *)dict\
{\
if (self=[super init]) {\
[self setValuesForKeysWithDictionary:dict];\
}\
return self;\
}\
\
+(instancetype)name##WithDict:(NSDictionary *)dict\
{\
return [[self alloc]initWithDict:dict];\
}\
#endif
視圖部分
YYtgcell.h文件
//
// YYtgcell.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "YYtgModel.h"
@interface YYtgcell : UITableViewCell
@property(nonatomic,strong)YYtgModel *yytg;
//把加載數(shù)據(jù)(使用xib創(chuàng)建cell的內(nèi)部細(xì)節(jié)進(jìn)行封裝)
+(instancetype)tgcellWithTableView:(UITableView *)tableView;
@end
YYtgcell.m文件
//
// YYtgcell.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYtgcell.h"
//私有擴(kuò)展
@interface YYtgcell()
@property (strong, nonatomic) IBOutlet UIImageView *img;
@property (strong, nonatomic) IBOutlet UILabel *titlelab;
@property (strong, nonatomic) IBOutlet UILabel *pricelab;
@property (strong, nonatomic) IBOutlet UILabel *buycountlab;
@end
@implementation YYtgcell
#pragma mark 重寫set方法,完成數(shù)據(jù)的賦值操作
-(void)setYytg:(YYtgModel *)yytg
{
_yytg=yytg;
self.img.image=[UIImage imageNamed:yytg.icon];
self.titlelab.text=yytg.title;
self.pricelab.text=[NSString stringWithFormat:@"$%@",yytg.price];
self.buycountlab.text=[NSString stringWithFormat:@"已有%@人購(gòu)買",yytg.buyCount];
}
+(instancetype)tgcellWithTableView:(UITableView *)tableView
{
static NSString *identifier= @"tg";
YYtgcell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==nil) {
//如何讓創(chuàng)建的cell加個(gè)戳
//對(duì)于加載的xib文件,可以到xib視圖的屬性選擇器中進(jìn)行設(shè)置
cell=[[[NSBundle mainBundle]loadNibNamed:@"tgcell" owner:nil options:nil]firstObject];
NSLog(@"創(chuàng)建了一個(gè)cell");
}
return cell;
}
@end
YYfooterview.h文件
//
// YYfooterview.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <UIKit/UIKit.h>
@class YYViewController;
@interface YYfooterview : UIView
@property(nonatomic,strong) YYViewController *controller;
@end
YYfooterview.m文件
//
// YYtgcell.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYtgcell.h"
//私有擴(kuò)展
@interface YYtgcell()
@property (strong, nonatomic) IBOutlet UIImageView *img;
@property (strong, nonatomic) IBOutlet UILabel *titlelab;
@property (strong, nonatomic) IBOutlet UILabel *pricelab;
@property (strong, nonatomic) IBOutlet UILabel *buycountlab;
@end
@implementation YYtgcell
#pragma mark 重寫set方法,完成數(shù)據(jù)的賦值操作
-(void)setYytg:(YYtgModel *)yytg
{
_yytg=yytg;
self.img.image=[UIImage imageNamed:yytg.icon];
self.titlelab.text=yytg.title;
self.pricelab.text=[NSString stringWithFormat:@"$%@",yytg.price];
self.buycountlab.text=[NSString stringWithFormat:@"已有%@人購(gòu)買",yytg.buyCount];
}
+(instancetype)tgcellWithTableView:(UITableView *)tableView
{
static NSString *identifier= @"tg";
YYtgcell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==nil) {
//如何讓創(chuàng)建的cell加個(gè)戳
//對(duì)于加載的xib文件,可以到xib視圖的屬性選擇器中進(jìn)行設(shè)置
cell=[[[NSBundle mainBundle]loadNibNamed:@"tgcell" owner:nil options:nil]firstObject];
NSLog(@"創(chuàng)建了一個(gè)cell");
}
return cell;
}
@end
YYfooterview.h文件
//
// YYfooterview.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <UIKit/UIKit.h>
@class YYViewController;
@interface YYfooterview : UIView
@property(nonatomic,strong) YYViewController *controller;
@end
YYfooterview.m文件
//
// YYfooterview.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYfooterview.h"
#import "YYViewController.h"
@interface YYfooterview ()
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *loadingview;
@property (strong, nonatomic) IBOutlet UIButton *loadbtn;
@end
@implementation YYfooterview
- (IBAction)loadbtclick {
NSLog(@"按鈕被點(diǎn)擊了");
//隱藏按鈕
self.loadbtn.hidden=YES;
//顯示菊花
self.loadingview.hidden=NO;
#warning 模擬發(fā)送網(wǎng)絡(luò)請(qǐng)求, 3秒之后隱藏菊花
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 3.調(diào)用控制的加載數(shù)據(jù)方法
[self.controller LoadMore];
// 4.隱藏菊花視圖
self.loadingview.hidden = YES;
// 5.顯示按鈕
self.loadbtn.hidden = NO;
});
}
@end
主控制器
YYViewController.h文件
//
// YYViewController.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface YYViewController : UIViewController
//公開接口
//- (void)LoadMore;
@end
YYViewController.m文件
//
// YYViewController.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYViewController.h"
#import "YYtgModel.h"
#import "YYtgcell.h"
#import "YYfooterview.h"
@interface YYViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableview;
@property(strong,nonatomic)NSMutableArray *tg;
@end
@implementation YYViewController
#pragma mark-加載數(shù)據(jù)方法
-(void)LoadMore
{
//創(chuàng)建模型
YYtgModel *tgmodel=[[YYtgModel alloc]init];
tgmodel.title=@"菜好上桌";
tgmodel.icon=@"5ee372ff039073317a49af5442748071";
tgmodel.buyCount=@"20";
tgmodel.price=@"10000";
//將模型添加到數(shù)組中
[self.tg addObject:tgmodel];
YYtgModel *tgmodelq=[[YYtgModel alloc]init];
tgmodelq.title=@"菜好上桌1";
tgmodelq.icon=@"5ee372ff039073317a49af5442748071";
tgmodelq.buyCount=@"20";
tgmodelq.price=@"10000";
[self.tg addObject:tgmodelq];
//刷新表格
[self.tableview reloadData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableview.rowHeight=80.f;
//加載底部視圖
//從xib中獲取數(shù)據(jù)
UINib *nib=[UINib nibWithNibName:@"YYfooterview" bundle:nil];
YYfooterview *footerview=[[nib instantiateWithOwner:nil options:nil] firstObject];
self.tableview.tableFooterView=footerview;
//設(shè)置控制
footerview.controller=self;
}
#pragma mark- 懶加載
-(NSArray *)tg
{
if (_tg==nil) {
NSString *fullpath=[[NSBundle mainBundle]pathForResource:@"tgs.plist" ofType:nil];
NSArray *temparray=[NSArray arrayWithContentsOfFile:fullpath];
NSMutableArray *arrayM=[NSMutableArray arrayWithCapacity:temparray.count];
for (NSDictionary *dict in temparray) {
YYtgModel *tg=[YYtgModel tgWithDict:dict];
[arrayM addObject:tg];
}
_tg=arrayM;
}
return _tg;
}
#pragma mark- xib創(chuàng)建cell數(shù)據(jù)處理
#pragma mark 多少組
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
#pragma mark多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.tg.count;
}
#pragma mark設(shè)置每組每行
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//1.創(chuàng)建cell
YYtgcell *cell=[YYtgcell tgcellWithTableView:tableView];
//2.獲取當(dāng)前行的模型,設(shè)置cell的數(shù)據(jù)
YYtgModel *tg=self.tg[indexPath.row];
cell.yytg=tg;
//3.返回cell
return cell;
}
#pragma mark- 隱藏狀態(tài)欄
-(BOOL)prefersStatusBarHidden
{
return YES;
}
@end
2.通過代理完成
當(dāng)按鈕被點(diǎn)擊的時(shí)候,視圖部分本身不干活,而是通知它的代理(控制器)完成接下來(lái)的操作。
該部分代碼在1的基礎(chǔ)上對(duì)下面幾個(gè)文件進(jìn)行了修改:
視圖部分:
YYfooterview.h文件
//
// YYfooterview.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <UIKit/UIKit.h>
@class YYViewController ,YYfooterview;
//約定協(xié)議
@protocol YYfooterviewDelegate <NSObject>
-(void)footerviewLoadMore;
@end
@interface YYfooterview : UIView
//聲明一個(gè)id類型屬性,遵守了協(xié)議的“人”即可成為它的代理
@property(nonatomic,strong)id<YYfooterviewDelegate> delegate;
//@property(nonatomic,strong) YYViewController *controller;
@end
YYfooterview.m文件
//
// YYfooterview.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYfooterview.h"
#import "YYViewController.h"
@interface YYfooterview ()
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *loadingview;
@property (strong, nonatomic) IBOutlet UIButton *loadbtn;
@end
@implementation YYfooterview
- (IBAction)loadbtclick {
NSLog(@"按鈕被點(diǎn)擊了");
//隱藏按鈕
self.loadbtn.hidden=YES;
//顯示菊花
self.loadingview.hidden=NO;
#warning 模擬發(fā)送網(wǎng)絡(luò)請(qǐng)求, 3秒之后隱藏菊花
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 3.調(diào)用控制的加載數(shù)據(jù)方法
// [self.controller LoadMore];
//通知代理
[self.delegate footerviewLoadMore];
// 4.隱藏菊花視圖
self.loadingview.hidden = YES;
// 5.顯示按鈕
self.loadbtn.hidden = NO;
});
}
@end
主控制器部分
YYViewController.h文件
//
// YYViewController.h
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface YYViewController : UIViewController
//公開接口
//- (void)LoadMore;
@end
YYViewController.m文件
//
// YYViewController.m
// 02-團(tuán)購(gòu)(使用xib和類完成數(shù)據(jù)展示)
//
// Created by apple on 14-5-29.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYViewController.h"
#import "YYtgModel.h"
#import "YYtgcell.h"
#import "YYfooterview.h"
@interface YYViewController ()<UITableViewDataSource,UITableViewDelegate,YYfooterviewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableview;
@property(strong,nonatomic)NSMutableArray *tg;
@end
@implementation YYViewController
#pragma mark-加載數(shù)據(jù)方法
-(void)footerviewLoadMore
{
//創(chuàng)建模型
YYtgModel *tgmodel=[[YYtgModel alloc]init];
tgmodel.title=@"菜好上桌";
tgmodel.icon=@"5ee372ff039073317a49af5442748071";
tgmodel.buyCount=@"20";
tgmodel.price=@"10000";
//將模型添加到數(shù)組中
[self.tg addObject:tgmodel];
YYtgModel *tgmodelq=[[YYtgModel alloc]init];
tgmodelq.title=@"菜好上桌1";
tgmodelq.icon=@"5ee372ff039073317a49af5442748071";
tgmodelq.buyCount=@"20";
tgmodelq.price=@"10000";
[self.tg addObject:tgmodelq];
//刷新表格
[self.tableview reloadData];
}
//-(void)LoadMore
//{
// //創(chuàng)建模型
// YYtgModel *tgmodel=[[YYtgModel alloc]init];
// tgmodel.title=@"菜好上桌";
// tgmodel.icon=@"5ee372ff039073317a49af5442748071";
// tgmodel.buyCount=@"20";
// tgmodel.price=@"10000";
// //將模型添加到數(shù)組中
// [self.tg addObject:tgmodel];
//
// YYtgModel *tgmodelq=[[YYtgModel alloc]init];
// tgmodelq.title=@"菜好上桌1";
// tgmodelq.icon=@"5ee372ff039073317a49af5442748071";
// tgmodelq.buyCount=@"20";
// tgmodelq.price=@"10000";
//
// [self.tg addObject:tgmodelq];
// //刷新表格
// [self.tableview reloadData];
//}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableview.rowHeight=80.f;
//加載底部視圖
//從xib中獲取數(shù)據(jù)
UINib *nib=[UINib nibWithNibName:@"YYfooterview" bundle:nil];
YYfooterview *footerview=[[nib instantiateWithOwner:nil options:nil] firstObject];
self.tableview.tableFooterView=footerview;
//設(shè)置控制
// footerview.controller=self;
//設(shè)置代理
footerview.delegate=self;
}
#pragma mark- 懶加載
-(NSArray *)tg
{
if (_tg==nil) {
NSString *fullpath=[[NSBundle mainBundle]pathForResource:@"tgs.plist" ofType:nil];
NSArray *temparray=[NSArray arrayWithContentsOfFile:fullpath];
NSMutableArray *arrayM=[NSMutableArray arrayWithCapacity:temparray.count];
for (NSDictionary *dict in temparray) {
YYtgModel *tg=[YYtgModel tgWithDict:dict];
[arrayM addObject:tg];
}
_tg=arrayM;
}
return _tg;
}
#pragma mark- xib創(chuàng)建cell數(shù)據(jù)處理
#pragma mark 多少組
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
#pragma mark多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.tg.count;
}
#pragma mark設(shè)置每組每行
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//1.創(chuàng)建cell
YYtgcell *cell=[YYtgcell tgcellWithTableView:tableView];
//2.獲取當(dāng)前行的模型,設(shè)置cell的數(shù)據(jù)
YYtgModel *tg=self.tg[indexPath.row];
cell.yytg=tg;
//3.返回cell
return cell;
}
#pragma mark- 隱藏狀態(tài)欄
-(BOOL)prefersStatusBarHidden
{
return YES;
}
@end
相關(guān)文章
IOS中的target action控件的實(shí)現(xiàn)
這篇文章主要介紹了IOS中的target action控件的實(shí)現(xiàn)的相關(guān)資料,這里提供實(shí)現(xiàn)target action的簡(jiǎn)單實(shí)例幫助大家學(xué)習(xí)理解該如何實(shí)現(xiàn),需要的朋友可以參考下2017-08-08iOS 隱私權(quán)限和通過openURL實(shí)現(xiàn)跳轉(zhuǎn)實(shí)例
這篇文章主要介紹了iOS 隱私權(quán)限和通過openURL實(shí)現(xiàn)跳轉(zhuǎn)實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06使用Swift代碼實(shí)現(xiàn)iOS手勢(shì)解鎖、指紋解鎖實(shí)例詳解
這篇文章主要介紹了使用Swift代碼實(shí)現(xiàn)iOS手勢(shì)解鎖、指紋解鎖的實(shí)現(xiàn)過程,非常不錯(cuò)具有參考借鑒價(jià)值,感興趣的朋友一起看看吧2016-06-06iOS開發(fā)中實(shí)現(xiàn)顯示gif圖片的方法
這篇文章主要介紹了iOS開發(fā)中實(shí)現(xiàn)顯示gif圖片的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-09-09iOS自定義button抖動(dòng)效果并實(shí)現(xiàn)右上角刪除按鈕
這篇文章主要為大家詳細(xì)介紹了iOS自定義button抖動(dòng)效果并實(shí)現(xiàn)右上角刪除按鈕的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03iOS開發(fā)之TextField禁用粘貼、選擇和全選功能
這篇文章主要為大家詳細(xì)介紹了iOS開發(fā)之TextField禁用粘貼、選擇和全選功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09