2015-12-24-UITableVIewController
//
// AppDelegate.h
// UI12_UITableVIewController
//
// 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 (strong, nonatomic) UIWindow *window;
@end
//
// AppDelegate.m
// UI12_UITableVIewController
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//
import "AppDelegate.h"
import "MyTableViewController.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 = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];MyTableViewController *myVC = [[MyTableViewController alloc]init];
UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:myVC];
self.window.rootViewController = navi;
[navi release];
[myVC 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
//
// MyTableViewController.h
// UI12_UITableVIewController
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//
import <UIKit/UIKit.h>
@interface MyTableViewController : UITableViewController
@end
//
// MyTableViewController.m
// UI12_UITableVIewController
//
// Created by YIem on 15/12/22.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//
import "MyTableViewController.h"
@interface MyTableViewController ()
@end
@implementation MyTableViewController
(void)viewDidLoad {
[super viewDidLoad]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem;
warning 如果使用tableViewCController 必须注册一个cell;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}
(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.
}
pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
warning Incomplete implementation, return the number of sections
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
warning Incomplete implementation, return the number of rows
return 10;
}
- (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];// Configure the cell...
cell.textLabel.text = @"你好啊";
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView )tableView canEditRowAtIndexPath:(NSIndexPath )indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
(void)tableView:(UITableView )tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath )indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {// Delete the row from the data source [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView )tableView moveRowAtIndexPath:(NSIndexPath )fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView )tableView canMoveRowAtIndexPath:(NSIndexPath )indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
/*
pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.
}
*/
@end
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »