小编Squ*_*onE的帖子

UISearchBar textDidChange没有触发

我是iOS编程的新手,我不确定为什么我的textDidChange功能没有触发.在网上搜索了一堆,但无法找出我的代码和其他人之间有什么不同.这是我的.h.m文件对于这个视图控制器的样子:

CategoryTableViewController.h:

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface CategoryTableViewController : UITableViewController


@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnBack;
@property (weak, nonatomic) IBOutlet UISearchBar *txtSearchBar;

@property (strong,nonatomic) NSArray *allCategories;
@property (strong,nonatomic) NSMutableArray *filteredCategories;

//A stack containing the parent categories used to get to the current category.
@property (strong, nonatomic) NSMutableArray *parentCategories;

@end
Run Code Online (Sandbox Code Playgroud)

来自CategoryTableViewController.m的相关代码:

-(void)txtSearchBar:(UISearchBar*)txtSearchBar textDidChange: (NSString*)text
{

    //do something
}
Run Code Online (Sandbox Code Playgroud)

我使用Xcode的ctrl + click + drag来创建对头文件中搜索栏的引用.我在textDidChange代码的开头放置断点和打印语句,但它们都没有被调用.有任何想法吗?

iphone xcode ios

2
推荐指数
1
解决办法
2782
查看次数

标签 统计

ios ×1

iphone ×1

xcode ×1