29,027
社区成员
发帖
与我相关
我的任务
分享
[code=objc]@interface fivetableview ()
@end
@implementation fivetableview
@synthesize dlists;
@synthesize dellist;
NSInteger i;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
dellist=[[NSMutableArray alloc]initWithCapacity:30];
dlists=[[NSMutableArray alloc] initWithCapacity:30 ];
[dlists addObject:@"大众化的"];
[dlists addObject:@"线条硬朗的"];
[dlists addObject:@"流线型的"];
[dlists addObject:@"大气的"];
[dlists addObject:@"时尚的"];
[dlists addObject:@"简约的"];
[dlists addObject:@"有力量感的"];
[dlists addObject:@"张扬的"];
[dlists addObject:@"霸气的"];
[dlists addObject:@"动感的"];
[dlists addObject:@"稳重的"];
[dlists addObject:@"优雅的"];
[dlists addObject:@"粗犷的"];
[dlists addObject:@"创新的"];
[dlists addObject:@"中性的"];
[dlists addObject:@"活力的"];
[dlists addObject:@"经典的"];
NSLog(@"%d",[dlists count]);
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [dlists count];
//return [dlists count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell4";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
NSInteger row = [indexPath row];
cell.textLabel.text = [self.dlists objectAtIndex:row];
NSLog(@"row=%d",row);
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
@end
[/code]