我一直在編程一個UITableView,並且每個單元都推動一個新的視圖,我所要做的是添加兩個新的部分,一個男性和一個女性,第一個和第二個語音需要在男性部分和第三個部分聲音需要在女性部分。iPhone UITableView部分
#import "FirstLevelViewController.h"
#import "SecondLevelViewController.h"
#import "DisclosureDetailController.h"
#import "SecondVoiceController.h"
#import "ThirdVoiceController.h"
@implementation FirstLevelViewController
@synthesize controllers;
-(void)viewDidLoad {
self.title = @"Voices";
NSMutableArray *male = [[NSMutableArray alloc] init];
DisclosureDetailController *th = [DisclosureDetailController alloc];
th.title = @"First Voice";
[male addObject:th];
[th release];
SecondVoiceController *array2 = [SecondVoiceController alloc];
array2.title = @"Second Voice";
[male addObject:array2];
[array2 release];
ThirdVoiceController *array3 = [ThirdVoiceController alloc];
array3.title = @"Third Voice";
[male addObject:array3];
[array3 release];
self.controllers = male;
[male release];
[super viewDidLoad];
}
-(void)viewDidUnload {
self.controllers = nil;
[super viewDidUnload];
}
-(void)dealloc {
[controllers release];
[super dealloc];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.controllers count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *FirstLevelCell= @"FirstLevelCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstLevelCell] autorelease];
}
NSUInteger row = [indexPath row];
SecondLevelViewController *controller = [controllers objectAtIndex:row];
cell.textLabel.text = controller.title;
cell.imageView.image = controller.rowImage;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
SecondLevelViewController *nextViewController = [self.controllers
objectAtIndex:row];
[self.navigationController pushViewController:nextViewController animated:YES];
}
所有我想要做的就是添加了兩個新節一兩雄一雌,第一和第二的聲音必須在男性部分和第三語音需要在女款。請幫助我們堅持一段時間!
請使用更具描述性標題 – vikingosegundo