Why disclosure indicator don't show?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 23:28:53

问题


When app run in simulator Disclosure indicator don't show.Because of this I can not go to Detail

NamesTableViewController.m :

#import "NamesTableViewController.h"

@interface NamesTableViewController ()
@property (nonatomic, copy) NSDictionary *propertyList;
@property (nonatomic, copy) NSArray *letters;
@property (nonatomic, copy)NSMutableArray *filteredNames;
@property (nonatomic, strong)UISearchController *searchController;


@end

@implementation NamesTableViewController

@synthesize propertyList,  letters, filteredNames, searchController;

- (void)viewDidLoad {
    [super viewDidLoad];

    UITableView *tableView = (id)[self.view viewWithTag:1];

    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

    filteredNames = [[NSMutableArray alloc]init];
    searchController = [[UISearchController alloc]init];

    //bura bax self yigishdir
    self.searchController.searchResultsUpdater = self;

    NSString *path = [[NSBundle mainBundle] pathForResource:@"names" ofType:@"plist"];
    self.propertyList = [NSDictionary dictionaryWithContentsOfFile:path];
    self.letters = [[self.propertyList allKeys] sortedArrayUsingSelector:@selector(compare:)];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if (tableView.tag == 1){

        return self.letters.count;

    }else {
        return 1;
    }

    }

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (tableView.tag == 1) {

        NSString *letter = self.letters[section];
        NSArray *keyValues = [self.propertyList[letter] allKeys];
        return keyValues.count;
    } else {


        return [filteredNames count];
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    // Configure the cell...

    if (tableView.tag == 1){

        NSString *letter = self.letters[indexPath.section];;
        NSArray *keyValues = [[self.propertyList[letter] allKeys] sortedArrayUsingSelector:@selector(compare:)];
        cell.textLabel.text = keyValues[indexPath.row];
    } else{
        cell.textLabel.text = filteredNames[indexPath.row];
    }
    return cell;
}

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return self.letters;
}

-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    if (tableView.tag == 1) {
        return letters [section];
    } else {
        return nil;
    }
}

#pragma mark Search Display Delegate Methods

-(void)searchDisplayController:(UISearchController *)controller didLoadSearchResultsTableView:(UITableView *)tableView {
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
}



-(BOOL)searchDisplayController:(UISearchController *)controller shouldReloadTableForSearchString:(NSString *)searchString

{

    [filteredNames removeAllObjects];
    if (searchString.length > 0) {
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains [search] %@", self.searchBar.text];

        for (NSString *letter in letters) {
            NSArray *matches = [[self.propertyList[letter] allKeys]filteredArrayUsingPredicate:predicate];

            [filteredNames addObjectsFromArray:matches];

        }

    }

    return YES;
}


@end

NamesTableViewController.h :

#import <UIKit/UIKit.h>


@interface NamesTableViewController : UITableViewController <UISearchDisplayDelegate, UISearchBarDelegate>


@property (strong, nonatomic) IBOutlet UISearchBar *searchBar;

@end

How can I accomplish this?Please help me. I am new


回答1:


try this

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    .......
}

Update

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here, for example: If your are used in connection 
// use this

   [self performSegueWithIdentifier:@"yourSegueName" sender:self];

 // if you are used connection less in storyboard , use this
 DetailViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
   // Push the view controller.
[self.navigationController pushViewController:vc animated:YES];


}


来源:https://stackoverflow.com/questions/35403921/why-disclosure-indicator-dont-show

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!