//
// AppDelegate.h
// UI12_RegisterCell
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end


//
// AppDelegate.m
// UI12_RegisterCell
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "AppDelegate.h"

import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

  • (void)dealloc
    {
    [_window release];
    [super dealloc];
    }
  • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    ViewController *rootVC = [[ViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:rootVC];
    self.window.rootViewController = navi;
    [navi release];
    [rootVC release];

    [_window release];
    return YES;
    }

  • (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
  • (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
  • (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
  • (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
  • (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

@end



//
// ViewController.h
// UI12_RegisterCell
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@end


//
// ViewController.m
// UI12_RegisterCell
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "ViewController.h"

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation ViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"RegisterCell";
    // tableView
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    [tableView release];
    // 注册cell重用池
    // 参数1. 注册重用池使用的cell类
    // 参数2. 重用标识
    // [对象/类 class] 获取对应类型
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    NSLog(@"%@", [UITableViewCell class]);

    }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    return 10;
    }
  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    // 只配合 reguistr使用
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = @"随便";

    return cell;
    }

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

@end