//생성.
alarmList = [[UITableView alloc] initWithFrame:CGRectMake(0, 45, 320, 366) style:UITableViewStylePlain];
alarmList.delegate = self;
alarmList.dataSource = self;
[self.view addSubview:alarmList];
[alarmList release];
//필수 함수
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//AlarmListCell *cell = (AlarmListCell *)[tableView dequeueReusableCellWithIdentifier:@"acell"];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"acell"];
if (cell == nil)
{
///cell = [[[AlarmListCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"acell"] autorelease];
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"acell"] autorelease];
}
cell.textLabel.text = @"오전9:33";
cell.detailTextLabel.text = @"알람";
[cell.textLabel setFont:[UIFont systemFontOfSize:17]];
cell.accessoryView = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
//accessory선택시 호출함수
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
//cell의 선 스타일 조절
alarmList.separatorStyle
0 -> 숨김 2->내용이 있는 셀만 숨김
//cell 선 색상 조절
alarmList.separatorColor = [UIColor whiteColor];
//cell 기본높이및 전체 높이 고정
alarmList.rowHeight = 80.0;
//edit모드에서 셀 선택하기
alarmList.allowsSelectionDuringEditing = YES
//전체 테이블 선택 방지
alarmList.allowsSelection = NO;
//특정 cell선택 방지
cell.selectionStyle = 0;
//cell선택 남아있는거 해결하고 싶을때는
UITableViewCell *cell = [alarmList cellForRowAtIndexPath:indexPath];
cell.selected = NO;
//cell Edit 모드에서 애니메이션
[tableName deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationLeft];
또는
[tavleName deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
//테이블 위치 재정렬 하기. indPath에 이동할 위치를 넣어주면 됨.
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:0];
[recordListView scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];