Code note: the animation is flipped when you click cell, and the cell animation is flipped.

Source: Internet
Author: User

Code note: the animation is flipped when you click cell, and the cell animation is flipped.

I ,.

2. Engineering Drawing.

3. Code.

RootViewController. h

#import <UIKit/UIKit.h>@interface RootViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{    UITableView *myTableView;}@end

 

RootViewController. m

# Import "RootViewController. h "@ interface RootViewController () @ end @ implementation RootViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // initialization background [self addView];} # pragma-mark-functions // initialization background-(void) addView {myTableView = [[UITableView alloc] initWithFrame: CGRectMake (0,100,320,300)]; myTableView. delegate = self; myTableView. dataSource = self; [self. view addSubview: myTableView];} # pragma-mark-UITableViewDelegate-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {return 5;}-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView {return 1;}-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath {return 40 *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {static NSString * CellIdentifier = @ "Cell"; UITableViewCell * cell = [tableView progress: CellIdentifier]; if (cell = nil) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier];} cell. textLabel. text = @ "1"; return cell;} // animation effect when clicked-(void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath {[UIView beginAnimations: @ "animationID" context: nil]; [UIView setAnimationDuration: 0.5f]; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; [UIView outputs: NO]; switch (indexPath. row) {case 0: [UIView setAnimationTransition: Rule forView: [tableView cellForRowAtIndexPath: indexPath] cache: YES]; break; case 1: [UIView setAnimationTransition: Rule forView: [tableView cellforrowatpath: indexPath] cache: YES]; break; case 2: [UIView setAnimationTransition: Rule forView: [tableView cellForRowAtIndexPath: indexPath] cache: YES]; break; case 3: [UIView setAnimationTransition: revoke forView: [tableView cellForRowAtIndexPath: indexPath] cache: YES]; break; default: break;} [UIView commitAnimations];}-(void) didreceivemorywarning {[super Resume]; // Dispose of any resources that can be recreated .}

 

 

Related Article

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.