AppDelegate.h
//
// AppDelegate.h
// TableVieww
//
// Created by Lab10 on 13. 8. 21..
// Copyright (c) 2013년 Lab10. All rights reserved.
//
#import <UIKit/UIKit.h>
@class RootViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UINavigationController *navigationController;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *navigationController;
@end
#import "AppDelegate.h"
//#import "ViewController.h"
#import "RootViewController.h"
@implementation AppDelegate
@synthesize window;
@synthesize navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 애플리케이션 시작 후 수행될 개발자가 원하는 코드를 추가하는 부분
UIViewController *rootController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
RootViewController.h
#import <UIKit/UIKit.h>
@class BooksViewController;
@interface RootViewController : UITableViewController
{
NSArray *authorList;
BooksViewController *booksController;
}
@property (strong, nonatomic) NSArray *authorList;
@property (strong, nonatomic) IBOutlet BooksViewController *booksController;
@end
#import "RootViewController.h"
#import "BooksViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
@synthesize authorList;
@synthesize booksController;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.authorList = [[NSArray alloc] initWithObjects:@"1월", @"2월", @"3월", nil];
self.title = @"Month";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.authorList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [self.authorList objectAtIndex:[indexPath row]];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(0 == indexPath.row)
{
self.booksController.title = @"1월";
}
else if(1 == indexPath.row)
{
self.booksController.title = @"2월";
}
else
{
self.booksController.title = @"3월";
}
[self.navigationController pushViewController:self.booksController animated:YES];
}
@end
BooksViewController.h
#import <UIKit/UIKit.h>
@class NiceViewController;
@interface BooksViewController : UITableViewController
{
NSArray *books;
NiceViewController *niceController;
}
@property (strong, nonatomic) NSArray *books;
@property (strong, nonatomic) IBOutlet NiceViewController *niceController;
@end
#import "BooksViewController.h"
#import "NiceViewController.h"
@interface BooksViewController ()
@end
@implementation BooksViewController
@synthesize books;
@synthesize niceController;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [books count];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if([self.title isEqualToString:@"1월"])
{
books = [[NSArray alloc] initWithObjects:@"1월 1일", @"1월 2일", @"1월 3일", @"1월 4일", @"1월 5일", @"1월 6일", nil];
}
else if([self.title isEqualToString:@"2월"])
{
books = [[NSArray alloc] initWithObjects:@"2월 1일", @"2월 2일", @"2월 3일", @"2월 4일", @"2월 5일", nil];
}
else
{
books = [[NSArray alloc] initWithObjects:@"3월 1일", @"3월 2일", @"3월 3일", @"3월 4일", @"3월 5일", @"3월 6일", nil];
}
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [books objectAtIndex:[indexPath row]];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if([self.title isEqualToString:@"1월"])
{
if(0 == indexPath.row)
{
self.niceController.title = @"1월 1일";
}
else if(1 == indexPath.row)
{
self.niceController.title = @"1월 2일";
}
else if(2 == indexPath.row)
{
self.niceController.title = @"1월 3일";
}
else if(3 == indexPath.row)
{
self.niceController.title = @"1월 4일";
}
else if(4 == indexPath.row)
{
self.niceController.title = @"1월 5일";
}
else
{
self.niceController.title = @"1월 6일";
}
}
else if([self.title isEqualToString:@"2월"])
{
if(0 == indexPath.row)
{
self.niceController.title = @"2월 1일";
}
else if(1 == indexPath.row)
{
self.niceController.title = @"2월 2일";
}
else if(2 == indexPath.row)
{
self.niceController.title = @"2월 3일";
}
else if(3 == indexPath.row)
{
self.niceController.title = @"2월 4일";
}
else
{
self.niceController.title = @"2월 5일";
}
}
else
{
if(0 == indexPath.row)
{
self.niceController.title = @"3월 1일";
}
else if(1 == indexPath.row)
{
self.niceController.title = @"3월 2일";
}
else if(2 == indexPath.row)
{
self.niceController.title = @"3월 3일";
}
else if(3 == indexPath.row)
{
self.niceController.title = @"3월 4일";
}
else if(4 == indexPath.row)
{
self.niceController.title = @"3월 5일";
}
else
{
self.niceController.title = @"3월 6일";
}
}
[self.navigationController pushViewController:self.niceController animated:YES];
}
@end
#import <UIKit/UIKit.h>
@interface NiceViewController : UITableViewController
{
NSArray *nice;
}
@property (strong, nonatomic) NSArray *nice;
@end
#import "NiceViewController.h"
@interface NiceViewController ()
@end
@implementation NiceViewController
@synthesize nice;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [nice count];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if([self.title isEqualToString:@"1월 1일"])
{
nice = [[NSArray alloc] initWithObjects:@"1kg", @"1cm", @"1세", @"여", nil];
}
else if([self.title isEqualToString:@"1월 2일"])
{
nice = [[NSArray alloc] initWithObjects:@"2kg", @"2cm", @"2세", @"남", nil];
}
else if([self.title isEqualToString:@"1월 3일"])
{
nice = [[NSArray alloc] initWithObjects:@"3kg", @"3cm", @"3세", @"남", nil];
}
else if([self.title isEqualToString:@"1월 4일"])
{
nice = [[NSArray alloc] initWithObjects:@"4kg", @"4cm", @"4세", @"남", nil];
}
else if([self.title isEqualToString:@"1월 5일"])
{
nice = [[NSArray alloc] initWithObjects:@"5kg", @"5cm", @"5세", @"남", nil];
}
else if([self.title isEqualToString:@"1월 6일"])
{
nice = [[NSArray alloc] initWithObjects:@"6kg", @"6cm", @"6세", @"남", nil];
}
else if([self.title isEqualToString:@"2월 1일"])
{
nice = [[NSArray alloc] initWithObjects:@"7kg", @"7cm", @"7세", @"남", nil];
}
else if([self.title isEqualToString:@"2월 2일"])
{
nice = [[NSArray alloc] initWithObjects:@"8kg", @"8cm", @"8세", @"남", nil];
}
else if([self.title isEqualToString:@"2월 3일"])
{
nice = [[NSArray alloc] initWithObjects:@"9kg", @"9cm", @"9세", @"남", nil];
}
else if([self.title isEqualToString:@"2월 4일"])
{
nice = [[NSArray alloc] initWithObjects:@"10kg", @"10cm", @"10세", @"남", nil];
}
else if([self.title isEqualToString:@"2월 5일"])
{
nice = [[NSArray alloc] initWithObjects:@"11kg", @"11cm", @"10세", @"남", nil];
}
else if([self.title isEqualToString:@"3월 1일"])
{
nice = [[NSArray alloc] initWithObjects:@"12kg", @"12cm", @"11세", @"남", nil];
}
else if([self.title isEqualToString:@"3월 2일"])
{
nice = [[NSArray alloc] initWithObjects:@"13kg", @"13cm", @"12세", @"남", nil];
}
else if([self.title isEqualToString:@"3월 3일"])
{
nice = [[NSArray alloc] initWithObjects:@"14kg", @"14cm", @"13세", @"남", nil];
}
else if([self.title isEqualToString:@"3월 4일"])
{
nice = [[NSArray alloc] initWithObjects:@"15kg", @"15cm", @"14세", @"남", nil];
}
else if([self.title isEqualToString:@"3월 5일"])
{
nice = [[NSArray alloc] initWithObjects:@"16kg", @"16cm", @"15세", @"남", nil];
}
else
{
nice = [[NSArray alloc] initWithObjects:@"17kg", @"17cm", @"16세", @"남", nil];
}
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.textLabel.text = [nice objectAtIndex:[indexPath row]];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end
'Programing > IOS' 카테고리의 다른 글
테이블뷰에 웹뷰가 포함된 소스 (0) | 2013.09.11 |
---|---|
카드 짝 맞추기 게임 (0) | 2013.08.29 |
Slider 및 TextField 및 OnOff 스위치 연습 (0) | 2013.08.26 |
기본 MP3 플레이어 기능 어플 (0) | 2013.08.21 |
숫자야구 게임으로 앱 흉내내기 (0) | 2013.08.20 |