iOS开发中使用UIScrollView实现图片轮播和点击加载

2020-01-14 18:27:14于丽

-(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创建cell数据处理

#pragma mark 多少组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

#pragma mark多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.tg.count;
}

#pragma mark设置每组每行
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //1.创建cell
    YYtgcell *cell=[YYtgcell tgcellWithTableView:tableView];
   
    //2.获取当前行的模型,设置cell的数据
    YYtgModel *tg=self.tg[indexPath.row];
    cell.yytg=tg;
    
    //3.返回cell
    return cell;
}

#pragma mark- 隐藏状态栏
-(BOOL)prefersStatusBarHidden
{
    return YES;
}

@end



注:相关教程知识阅读请移步到IOS开发频道。