【发布时间】:2015-08-03 19:15:56
【问题描述】:
我的 tableview segue 和详细视图控制器有问题。我设法用 nsdictionary 的标题和副标题填充我的表格视图。但是我无法将我的标题和副标题推送到详细视图。我需要在导航栏上显示我的标题,并在详细视图中显示标签的副标题。这是我的表格视图和详细视图的代码和屏幕截图:
#import "TableViewController.h"
#import "DetailViewController.h"
@interface TableViewController (){
NSDictionary *sarkilar;
NSArray *sarkilarSectionTitles;
NSArray *sarkilarIndexTitles;
}
@end
@implementation TableViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *newButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
[[self navigationItem] setBackBarButtonItem:newButton];
sarkilar = @{
@"A" : @[@{@"title":@"Alayına İsyan",@"subtitle":@"Seslendiren: Mustafa Sandal"},
@{@"title":@"Ardindan",@"subtitle":@"Seslendiren: Sinasi Gurel"}],
@"B" : @[@{@"title":@"Birak Gitsin",@"subtitle":@"Seslendiren: Tarkan"},
@{@"title":@"Buralar",@"subtitle":@"Seslendiren: Duman"}],
@"C" : @[@{@"title":@"Cephaneler",@"subtitle":@"Seslendiren: Burak Kut"},
@{@"title":@"Cari Acik",@"subtitle":@"Seslendiren: Kristal"}],
};
sarkilarSectionTitles = [[sarkilar allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
sarkilarIndexTitles = @[@"A", @"B", @"C",@"Ç", @"D", @"E", @"F", @"G", @"H", @"I",@"İ", @"J", @"K", @"L", @"M", @"N", @"O", @"Ö", @"P", @"R", @"S",@"Ş", @"T", @"U",@"Ü", @"V", @"Y", @"Z"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [sarkilarSectionTitles count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSString *sectionTitle = [sarkilarSectionTitles objectAtIndex:section];
NSArray *sectionSarkilar = [sarkilar objectForKey:sectionTitle];
return [sectionSarkilar count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [sarkilarSectionTitles objectAtIndex:section];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSString *sectionTitle = [sarkilarSectionTitles objectAtIndex:indexPath.section];
NSArray *sectionSarkilar = [sarkilar objectForKey:sectionTitle];
NSDictionary *dict = [sectionSarkilar objectAtIndex:indexPath.row];
NSString *title = [dict objectForKey:@"title"];
NSString *subtitle = [dict objectForKey:@"subtitle"];
cell.textLabel.text = title;
cell.detailTextLabel.text = subtitle;
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
// return animalSectionTitles;
return sarkilarIndexTitles;
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return [sarkilarSectionTitles indexOfObject:title];
}
//-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//
// if ([[segue identifier] isEqualToString:@"ShowDetails"]) {
// DetailViewController *detailView = [segue destinationViewController];
//
// NSIndexPath *myindexpath = [self.tableView indexPathForSelectedRow];
//
// int row = [myindexpath row];
// detailView.DetailModal = @[_title[row], subtitle[row],];
// }
//
//
//
//}
//
@end
如您所见,我不知道如何设置我的 segue。这是屏幕截图。我希望问如何设置segue不要太多
【问题讨论】:
标签: ios objective-c uitableview segue detailview