Imitation 58 City UITableViewCell Animation

Source: Internet
Author: User

Before looking at 58 the same city app has a page in which the cell moves from right to left and tries to do it today.

In the process of doing also encountered a few small problems, it is also a point of attention.

1.Cell occurs when the animation time of each cell is the same, causing no effect to move in turn.

According to the Indexpath to set the cell animation time, worry about the time when the most behind the cell will appear very slow, want to let indexpath%20 this to solve, but the decision effect is not ideal, so it is still directly with the Indexpath to set the animation time

2. Cell start point is always at TableView (0,0) point when reusing reload

Previously thought that the cell's parent view is not tableview (I am not sure what it is), set the cell's Y to 0 when setting the cell animation, which leads to the above problem, you should calculate the position of Y according to Indexpath and each rowheight.

3.cell will also have animation when it appears, swipe up when the top of the first out, slightly below the back out

Thinking of having the cell animation run only once will not cause the cell animation to be confusing.

4. Code

////VIEWCONTROLLER.M//Tableviewcell////Created by City--online on 15/11/9.//copyright©2015 year City--online. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () <UITableViewDataSource,UITableViewDelegate>@property (nonatomic,strong) UITableView*TableView, @property (nonatomic,strong) Nsmutablearray*showedindexpaths;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; _showedindexpaths=[[Nsmutablearray alloc]init]; _tableview=[[UITableView alloc]initwithframe:self.view.bounds Style:uitableviewstyleplain]; _tableview.Delegate=Self ; _tableview.datasource=Self ; _tableview.tablefooterview=[[UIView Alloc]initwithframe:cgrectzero]; _tableview.tableheaderview=[[UIView Alloc]initwithframe:cgrectzero]; [_tableview Registerclass:[uitableviewcellclass] Forcellreuseidentifier:@"Cell"]; [Self.view Addsubview:_tableview];}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{return  -;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{UITableViewCell*cell=[tableview Dequeuereusablecellwithidentifier:@"Cell"Forindexpath:indexpath]; Cell.textLabel.text=[nsstring stringWithFormat:@"123abc%ld", Indexpath.row]; returncell;}- (void) TableView: (UITableView *) TableView Willdisplaycell: (UITableViewCell *) cell Forrowatindexpath: (Nsindexpath *) indexpath{//Indexpath The first time the animation is loaded or not    if([_showedindexpaths Containsobject:indexpath]) {return; }    Else{[_showedindexpaths addobject:indexpath]; Cell.frame=cgrectmake (Self.view.bounds.size.width, indexpath.row*[_tableview rectforrowatindexpath:indexpath].size.height, Cell.bounds.size.width, Cell.bounds.size.height]; [UIView animatewithduration: (indexpath.row)*0.05animations:^{cell.frame=cgrectmake (0, indexpath.row*[_tableview rectforrowatindexpath:indexpath].size.height, Cell.bounds.size.width, Cell.bounds.size.height];    }]; }}-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{return  -;}- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}@end

5. Effects

Imitation 58 City UITableViewCell Animation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.