0
나는 간단한 UITableView가 있습니다. 행을 선택할 때마다 체크 표시를 추가하고 싶습니다. 내 테이블에는 단 하나의 섹션 만 있습니다. 누군가가 이걸 도와 줄 수 있어요.UITableView에서 독점 목록 관리
SampleTable.h
@interface SampleTable : UITableView <UITableViewDelegate , UITableViewDataSource>
{
NSMutableArray *itemArray;
NSString *itemValue;
}
@property (nonatomic,retain) NSMutableArray *itemArray;
@property (nonatomic,retain) NSString *itemValue;
-(NSMutableArray *) displayItemArray;
@end
SampleTable.m는
#import "SampleTable.h"
@implementation DropTableView
@synthesize itemArray,itemValue;
-(id)initWithFrame:(CGRect)frm
{
if(self=[super initWithFrame:frm])
{
[self displayItemArray];
self.delegate=self;
self.dataSource=self;
self.separatorStyle=UITableViewCellSeparatorStyleNone;
}
return self;
}
-(NSMutableArray *) displayItemArray {
if(itemArray==nil) {
itemArray=[[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",nil];
}
return itemArray;
}
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.itemArray 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];
[cell autorelease];
}
[self flashScrollIndicators];
self.scrollEnabled=YES;
[self showsVerticalScrollIndicator];
cell.textLabel.text = [self.itemArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//stuff
}
-(void) dealloc
{
[itemValue release];
[itemArray release];
[super dealloc];
}
@end