DataTable
= [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
[DataTable
setDelegate:self];
[DataTable
setDataSource:self];
[self.view
addSubview:DataTable];
[DataTable
release];
-
(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return
TitleData;
}
-
(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return
@
""
;
}
-
(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return
4;
}
-
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
}
-(UITableViewCell
*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static
NSString *SimpleTableIdentifier = @
"SimpleTableIdentifier"
;
UITableViewCell
*cell = [tableView dequeueReusableCellWithIdentifier:
SimpleTableIdentifier];
if
(cell == nil) {
cell
= [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:
SimpleTableIdentifier] autorelease];
}
cell.imageView.image=image;
cell.imageView.highlightedImage=highlightImage;
cell.text=
return
cell;
}
-(NSInteger)tableView:(UITableView
*)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{
NSUInteger
row = [indexPath row];
return
row;
}
-
(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return
40;
}
[TopicsTable
setContentOffset:CGPointMake(0, promiseNum * 44 + Chapter * 20)];
NSIndexPath
*ip = [NSIndexPath indexPathForRow:row inSection:section];
[TopicsTable
selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionNone];
[tableView
setSeparatorStyle:UITableViewCellSelectionStyleNone];
-
(
void
)tableView:(UITableView
*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView
deselectRowAtIndexPath:indexPath animated:YES];
}
-(NSIndexPath
*)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger
row = [indexPath row];
if
(row == 0)
return
nil;
return
indexPath;
}
-
(
BOOL
)tableView:(UITableView
*)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
}
-
(
void
)tableView:(UITableView
*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath
*)indexPath
{
}
[topicsTable
setContentSize:CGSizeMake(0,controller.promiseNum * 44)];
-
(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
}
-
(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
}
-
(NSString *)tableView:(UITableView *)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath
*)indexPath
[tableView
scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
三、在UITableViewCell上建立UILable多行显示
-
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static
NSString *CellIdentifier = @
"Cell"
;
UITableViewCell
*cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if
(cell == nil) {
cell
= [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel
*Datalabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 320, 44)];
[Datalabel
setTag:100];
Datalabel.autoresizingMask
= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[cell.contentView
addSubview:Datalabel];
[Datalabel
release];
}
UILabel
*Datalabel = (UILabel *)[cell.contentView viewWithTag:100];
[Datalabel
setFont:[UIFont boldSystemFontOfSize:18]];
Datalabel.text
= [data.DataArray objectAtIndex:indexPath.row];
cell.accessoryType
= UITableViewCellAccessoryDisclosureIndicator;
return
cell;
}
typedef
enum
{
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
}
UITableViewCellSelectionStyle
typedef
enum
{
UITableViewCellAccessoryNone,
UITableViewCellAccessoryDisclosureIndicator,
UITableViewCellAccessoryDetailDisclosureButton,
UITableViewCellAccessoryCheckmark
}
UITableViewCellAccessoryType
typedef
enum
{
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine
}
UITableViewCellSeparatorStyle
tableView.separatorColor
= [UIColor blueColor];