우회해서 짜는 방법이 여렀있었으나 가장 마음에 든건..
CardLayout 활용

....
Container ct;

CardLayout card;
JPanel card1;
JPanel card2;

ct.add(card1, "card1");
ct.add(card2, "card2");

card.show(ct, "card1");
....




Posted by 김반장78
,

#import "AddCityController.h"

#import "CityGuideDelegate.h"

#import "RootController.h"

#import "City.h";


@implementation AddCityController


#pragma mark ViewController Methods


- (void)didReceiveMemoryWarning {

// Releases the view if it doesn't have a superview.

    [super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.

}


- (void)viewDidLoad {

self.title = @"New City";

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveCity:)];

cityPicture = [UIImage imageNamed:@"QuestionMark.jpg"];

pickerController = [[UIImagePickerController alloc] init];

pickerController.allowsEditing = NO;

pickerController.delegate = self;

pickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;


}


- (void)viewDidUnload {

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

}



- (void)dealloc {

[tableView release];

[nameCell release];

[pictureCell release];

[descriptionCell release];

[pickerController release];

    [super dealloc];

}


#pragma mark Instance Methods

- (void)saveCity:(id)sender {

CityGuideDelegate *delegate = (CityGuideDelegate *)[[UIApplication sharedApplication] delegate];

NSMutableArray *cities = delegate.cities;

UITextField *nameEntry = (UITextField *)[nameCell viewWithTag:777];

UITextView *descriptionEntry = (UITextView *)[descriptionCell viewWithTag:777];

if ( nameEntry.text.length > 0 ) {

City *newCity = [[City alloc] init];

newCity.cityName = nameEntry.text;

newCity.cityDescription = descriptionEntry.text;

newCity.cityPicture = cityPicture;

[cities addObject:newCity];

RootController *viewController = delegate.viewController;

[viewController.tableView reloadData];

}

[delegate.navController popViewControllerAnimated:YES];

}


- (IBAction)addPicture:(id)sender {

UITextField *nameEntry = (UITextField *)[nameCell viewWithTag:777];

[nameEntry resignFirstResponder];

[self presentModalViewController:pickerController animated:YES];

}


#pragma mark UIImagePickerController Methods


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

[self dismissModalViewControllerAnimated:YES];


cityPicture = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

UIImageView *pictureView = (UIImageView *)[pictureCell viewWithTag:777];

pictureView.image = cityPicture;

[tableView reloadData];

}


#pragma mark UITableViewDataSource Methods


- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = nil;

if( indexPath.row == 0 ) {

cell = nameCell;

} else if ( indexPath.row == 1 ) {

UIImageView *pictureView = (UIImageView *)[pictureCell viewWithTag:777];

pictureView.image = cityPicture;

cell = pictureCell;

} else {

cell = descriptionCell;

}

return cell;

}


- (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section {

return 3;

}


#pragma mark UITableViewDelegate Methods


- (CGFloat)tableView:(UITableView *)tv heightForRowAtIndexPath:(NSIndexPath *)indexPath {

CGFloat height;

if( indexPath.row == 0 ) {

height = 44;

} else if( indexPath.row == 1 ) {

height = 83;

} else {

height = 279;

}

return height;

}


@end


Posted by 김반장78
,

보고 재미있는거만 남길 생각이였는데 미묘..


걍 영어공부와 시간때우기로는 적당할지도 
2편은 왠지 조금 기대..

'취미' 카테고리의 다른 글

[영화] 시라노 연애조작단  (0) 2011.02.04
[게임] 스타크레프트2 이정훈  (0) 2010.12.07
[게임] 몬스터헌터3rd 포터블  (0) 2010.12.06
메이지 신궁 산보..  (0) 2010.12.06
시금치  (0) 2010.11.21
Posted by 김반장78
,