为啥不显示披露指标?
Posted
技术标签:
【中文标题】为啥不显示披露指标?【英文标题】:Why disclosure indicator don't show?为什么不显示披露指标? 【发布时间】:2016-02-15 07:44:17 【问题描述】:当应用程序在模拟器中运行时,披露指示器不显示。因此,我无法进入详细信息
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
我怎样才能做到这一点?请帮助我。我是新人
【问题讨论】:
你的detailViewController是什么?您如何导航到 detailViewController?您是在使用任何segue
还是将其推送到您的 didselectrowAtIndexPath
中?您可以在代码或界面构建器中设置配件类型。
我在界面生成器中设置但在运行应用程序时不起作用。我使用segue(显示)
您的 detailViewController 在情节提要中?是否嵌入在导航控制器中?
是的。当然我添加了
【参考方案1】:
试试这个
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
.......
更新
- (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];
【讨论】:
显示附件。但不要去 DetailViewController 我怎样才能做到这一点? 如果你点击UITableViewCellAccessoryDisclosureIndicator
你不想执行任何操作,更正
当我点击 go to detailviewcontroller 时我想要
@FaHu -- 最后一个疑问,你的detailviewcontroller
被添加到storyboard或者xib中以上是关于为啥不显示披露指标?的主要内容,如果未能解决你的问题,请参考以下文章
我在披露指标中看到了双 V 形。为啥以及如何解决这个问题? [关闭]
为啥 TensorFlow 对象检测 2.x 在训练模型时不显示 mAP