저는 UITableView를 가지고 있고 그것을 만들 때 두 개의 행만 표시됩니다. 각 섹션에는 표시 할 셀이 3 개 이상 있습니다. 모두 동일하게 처리되었으므로 혼란 스럽습니다.왜 내 UITableView는 각 섹션에 2 행만 표시합니까?
#import #import "Store.h"
#import "VideoViewController.h"
@implementation Store
@synthesize listData;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[self createTableData];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
//self.listData = nil;
//[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
#pragma mark -
#pragma mark Table View Data Source Methods
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [videoSections count];
}
//Get number of rows
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [self.listData count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *StoreTableIdentifier = @"StoreTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:StoreTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:StoreTableIdentifier] autorelease];
}
cell.textLabel.text = [[[listData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]
objectForKey:@"name"];
//Change font and color of tableView
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font=[UIFont fontWithName:@"Georgia" size:16.0];
cell.textLabel.textColor = [UIColor brownColor];
return cell;
}
-(NSString *)tableView: (UITableView *)tableView titleForHeaderInSection: (NSInteger) section {
return [videoSections objectAtIndex:section];
}
-(void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {
VideoViewController *videoViewController = [[VideoViewController alloc] initWithNibName:
@"VideoViewController" bundle:nil];
videoViewController.detailURL = [[NSURL alloc] initWithString:
[[[listData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]
objectForKey:@"url"]];
videoViewController.title = [[[listData objectAtIndex:indexPath.section]
objectAtIndex:indexPath.row] objectForKey:@"name"];
[self.navigationController pushViewController:videoViewController animated:YES];
[videoViewController release];
}
#pragma mark Table View Methods
//Data in table cell
-(void) createTableData
{
NSMutableArray *beginningVideos;
NSMutableArray *intermediateVideos;
videoSections = [[NSMutableArray alloc] initWithObjects:
@"Beginning Videos", @"Intermediate Videos", nil];
beginningVideos = [[NSMutableArray alloc] init];
intermediateVideos = [[NSMutableArray alloc] init];
[beginningVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Shirts", @"name",
@"http://www.andalee.com/iPhoneVideos/testMovie.m4v", @"url", nil]];
[beginningVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Posters", @"name",
@"http://devimages.apple.com/iphone/samples/bipbopall.html", @"url", nil]];
[beginningVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Stickers",@"name",
@"http://www.andalee.com/iPhoneVideos/mov.MOV",@"url",nil]];
[beginningVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Egyptian",@"name",
@"http://www.andalee.com/iPhoneVideos/2ndMovie.MOV",@"url",nil]];
[intermediateVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Drum Solo", @"name",
@"http://www.andalee.com", @"url", nil]];
[intermediateVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Veil", @"name",
@"http://www.andalee.com", @"url", nil]];
[intermediateVideos addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Three Quarter Shimmy",@"name",
@"http://www.andalee.com",
@"url",nil]];
listData = [[NSMutableArray alloc] initWithObjects:beginningVideos, intermediateVideos, nil];
[beginningVideos release];
[intermediateVideos release];
}
- (void)dealloc {
[listData release];
[videoSections release];
[super dealloc];
}
@end
당신 거 수정해야 쉽게 읽을 수 있도록 여기에 서식을 지정하십시오. – WrightsCS