简体   繁体   English

获取-[SearchViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例

[英]Getting -[SearchViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance

The following is the code for a View Controller in which I'm adding a Search bar and performing things: 以下是View Controller的代码,其中添加了搜索栏并执行操作:

SearchViewController.h SearchViewController.h

#import <UIKit/UIKit.h>

@interface SearchViewController : UIViewController <UITextFieldDelegate>

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

@end

SearchViewController.m SearchViewController.m

#import "SearchViewController.h"
#import "MMDrawerController/UIViewController+MMDrawerController.h"

@interface SearchViewController ()

@end

@implementation SearchViewController

@synthesize search;

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [search.delegate self];

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];

    [self.view addGestureRecognizer:tap];
    [search setShowsCancelButton:YES animated:NO];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITextFieldMethod

-(void) textFieldDidEndEditing:(UITextField *)textField
{
    [search resignFirstResponder];
}

-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
    [search resignFirstResponder];
    return YES;
}

#pragma mark - HandlingKeyboard

-(void) dismissKeyboard
{
    [search resignFirstResponder];
}

#pragma mark - UISearchBarMethods

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    [search resignFirstResponder];
    [search endEditing:YES];
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
}

- (void) searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    [search resignFirstResponder];
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
}

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
    [search resignFirstResponder];
}

@end

While clicking in the search bar to enter text, I'm getting an error of: 在搜索栏中单击以输入文本时,出现以下错误:

-[SearchViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8e68990 -[SearchViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例0x8e68990

From error it looks like that your app try too find table view delegate methods. 从错误看来您的应用程序也尝试查找表视图委托方法。 Couple of check 几张支票

  1. Can you remove code for "MMDrawerController/UIViewController+MMDrawerController.h" and try? 您可以删除“ MMDrawerController / UIViewController + MMDrawerController.h”的代码并尝试吗?
  2. Does your nib file contain table view? 您的nib文件是否包含表格视图? If yes can you check if its connected to any IBOutlets or not? 如果是,您可以检查其是否连接到任何IBOutlets?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [UIViewController tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 - [UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance -[UIViewController tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 - -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 - tableView:numberOfRowsInSection:]: unrecognized selector sent to instance tableview无法正常工作 - [UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例 - tableview not working - [UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance &#39;NSInvalidArgumentException&#39;-[UIViewController tableView:numberOfRowsInSection:]-无法识别的选择器已发送到实例 - 'NSInvalidArgumentException' - [UIViewController tableView:numberOfRowsInSection:] - unrecognized selector sent to instance numberOfRowsInSection - 无法识别的选择器发送到实例问题 - numberOfRowsInSection - unrecognized selector sent to instance issue -[UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例0x7fc748e37ea0&#39; - -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fc748e37ea0' -[UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例0x7ff437517770 - -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff437517770 TableView在reloadData上崩溃 - &#39;无法识别的选择器发送到实例&#39; - TableView Crashes on reloadData - 'unrecognized selector sent to instance' 无法识别的选择器已发送到实例tableview swift - Unrecognized selector sent to instance tableview swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM