//
// _6_UITableViewViewController.h
#import <UIKit/UIKit.h>
@interface _6_UITableViewViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *tView;
NSArray *photoArray;
}
@property(retain, nonatomic) IBOutlet UITableView *tView;
@property(readonly) IBOutlet NSArray *photoArray;
-(NSArray *)createPhotoData;
@end
//
// _6_UITableViewViewController.m
#import "_6_UITableViewViewController.h"
@implementation _6_UITableViewViewController
@synthesize tView, photoArray;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
tView.delegate = self;
tView.dataSource = self;
photoArray = [[NSArray alloc] initWithArray:[self createPhotoData]];
}
-(NSArray *) createPhotoData{
UIImage *thumbnail;
thumbnail = [UIImage imageNamed:@"Africa_Morocco.jpg"];
NSDictionary *africa = [NSDictionary dictionaryWithObjectsAndKeys:
@"Africa",@"region",
@"Morocco",@"country",
thumbnail,@"thumbnail", nil];
thumbnail = [UIImage imageNamed:@"Asia_Japen.jpg"];
NSDictionary *asia = [NSDictionary dictionaryWithObjectsAndKeys:
@"Asia",@"region",
@"Japan",@"country",
thumbnail,@"thumbnail",nil];
thumbnail = [UIImage imageNamed:@"Europe_Swiss.jpg"];
NSDictionary *europe = [NSDictionary dictionaryWithObjectsAndKeys:
@"Europe",@"region",
@"Swiss",@"country",
thumbnail,@"thumbnail",nil];
NSArray *array = [NSArray arrayWithObjects:africa, asia, europe, nil];
return array;
}
- (NSInteger)numberOfSectionsInTableView:
(UITableView *)tableView // 섹션수
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section //섹션당 행의수
{
return [photoArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath // 셀관련 내용
{
static NSString *CellIdentifier=@"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
// 메모리 할당 받은것이 있는지..
if(cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle /*******/
reuseIdentifier:CellIdentifier] autorelease];
}
// 테이블 스타일 종류
// UITableViewCellStyleDefault : UI - 14
// UITableViewCellStyleValue1
// UITableViewCellStyleValue2 : UI - 15
// UITableViewCellStyleSubtitle : UI - 16
NSDictionary *photoData = [photoArray objectAtIndex:indexPath.row];
cell.textLabel.text = [photoData valueForKey:@"country"]; // Morocco
cell.detailTextLabel.text = [photoData valueForKey:@"region"]; // Africa
cell.imageView.image = [photoData valueForKey:@"thumbnail"]; // 이미지
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//오른쪽 화살표 버튼
//cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
//cell.accessoryType = UITableViewCellAccessoryCheckmark;
//테이블에서 뿌려줄수 있는 모든것....
//*********** 6월 15일 추가..
UIImage *highlighted = [UIImage imageNamed:@"Blog.png"];
cell.imageView.highlightedImage = highlighted;
//***********
return cell;
}
//*********** 6월 15일 추가..
// 리스트 높이
-(CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath{
CGFloat height;
height = 100;
return height;
}
//***********
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
}
- (void)dealloc {
[tView release];
[photoArray release];
[super dealloc];
}
@end
'프로그래밍 > iOS' 카테고리의 다른 글
backBarButtonItem 은 적용이 안된다?? (1) | 2011.07.29 |
---|---|
UITableViewCell의 프로퍼티 외에 이것이 지원하는 프로퍼티와 메소드 (0) | 2011.07.26 |
iOS 개발자 라이센스 비교 (0) | 2011.07.13 |
webview에서 Link 클릭했을때 이벤트 얻기 (0) | 2011.07.12 |
tableview에 "Twenty Five More..." 같은 기능 (0) | 2011.07.05 |