ios開發之--UITableView中的visibleCells的用法

來源:互聯網
上載者:User

標籤:creat   xpath   elf   content   tab   tag   ber   owa   for   

先:

 

具體代碼如下:

#import "ViewController.h"@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>@property(nonatomic,strong)UITableView *myTableV;@property(nonatomic,strong)NSArray *contentAry;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    self.contentAry = [NSArray array];    [self creatUI];}- (IBAction)leftAction:(id)sender {    self.contentAry = self.myTableV.visibleCells;    NSLog(@"----%@",self.contentAry);        UIButton *button = (UIButton*)sender;    button.selected = !button.selected;    CGAffineTransform transform;    double duration = 0.1;        if (button.tag == 1) {        transform = CGAffineTransformMakeTranslation(-[UIScreen mainScreen].bounds.size.width, 0);    }else if (button.tag == 2)    {        for (UITableViewCell *cell in self.contentAry) {            [UIView animateWithDuration:duration delay:0 options:0 animations:^{                cell.transform = CGAffineTransformIdentity;            } completion:^(BOOL finished) {                            }];            duration += 0.1;        }        return;    }else    {        transform = CGAffineTransformMakeTranslation([UIScreen mainScreen].bounds.size.width, 0);    }        for (UITableViewCell *cell in self.contentAry) {        [UIView animateWithDuration:duration delay:0 options:0 animations:^{            cell.transform = transform;        } completion:^(BOOL finished) {                    }];        duration += 0.1;    }    }-(void)creatUI{    self.myTableV = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 100) style:UITableViewStylePlain];    self.myTableV.delegate = self;    self.myTableV.dataSource = self;    self.myTableV.tableFooterView = [[UIView alloc]init];    [self.view addSubview:self.myTableV];}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return 5;}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *celliden = @"CELLS";    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:celliden];    if (!cell) {        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:celliden];    }    cell.textLabel.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row];    cell.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.6];    return cell;}

僅做記錄!

ios開發之--UITableView中的visibleCells的用法

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.