Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UISearchBar推送数据问题_Ios_Objective C_Xcode_Uisearchbar - Fatal编程技术网

Ios UISearchBar推送数据问题

Ios UISearchBar推送数据问题,ios,objective-c,xcode,uisearchbar,Ios,Objective C,Xcode,Uisearchbar,我已经在我的应用程序中实现了一个搜索栏,我一直试图解决一个问题,但似乎在任何地方都找不到解决方案。当您点击搜索栏并键入某个状态时,您可以选择按该状态,它会将您带到该状态下的区域。它确实会带你到各个领域,但每次都会带你到相同的信息。。。。我将在下面展示屏幕截图,也很抱歉这是一篇很长的帖子,我只是想确保你们都理解我所说的图片和代码 搜索阿拉巴马州: #import <UIKit/UIKit.h> @interface RootTableViewController : UITableV

我已经在我的应用程序中实现了一个搜索栏,我一直试图解决一个问题,但似乎在任何地方都找不到解决方案。当您点击搜索栏并键入某个状态时,您可以选择按该状态,它会将您带到该状态下的区域。它确实会带你到各个领域,但每次都会带你到相同的信息。。。。我将在下面展示屏幕截图,也很抱歉这是一篇很长的帖子,我只是想确保你们都理解我所说的图片和代码

搜索阿拉巴马州:

#import <UIKit/UIKit.h>

@interface RootTableViewController : UITableViewController

@property (nonatomic, strong) NSMutableArray *objects;
@property (nonatomic, strong) NSMutableArray *results;

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


@end

阿拉巴马州结果:

#import <UIKit/UIKit.h>

@interface RootTableViewController : UITableViewController

@property (nonatomic, strong) NSMutableArray *objects;
@property (nonatomic, strong) NSMutableArray *results;

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


@end

搜索科罗拉多州:

#import <UIKit/UIKit.h>

@interface RootTableViewController : UITableViewController

@property (nonatomic, strong) NSMutableArray *objects;
@property (nonatomic, strong) NSMutableArray *results;

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


@end

科罗拉多州结果:

#import <UIKit/UIKit.h>

@interface RootTableViewController : UITableViewController

@property (nonatomic, strong) NSMutableArray *objects;
@property (nonatomic, strong) NSMutableArray *results;

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


@end

正如你所看到的,它每次都给我相同的结果(阿拉巴马州的结果)。我想让它给我的结果,为国家的压力(阿拉巴马州->阿拉巴马州地区,科罗拉多州->科罗拉多州地区)。我知道这与我的prepareForSegue方法有关,但似乎不知道到底要更改什么。我现在将在下面发布我的代码:

RootTableViewController.h:

#import <UIKit/UIKit.h>

@interface RootTableViewController : UITableViewController

@property (nonatomic, strong) NSMutableArray *objects;
@property (nonatomic, strong) NSMutableArray *results;

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


@end

谢谢

我解决了我的问题,我需要在我的文章底部添加以下内容:

destViewController.stateName = object;
与此相反:

destViewController.stateName = [states objectAtIndex:indexPath.row];

我没有使用performsguewithidentifier的经验,但每当我有这样的实现时,我都会根据didSelectRowAtIndexPath中的选择来处理差异。通常您会执行类似NSString*selectedState=self.results[indexPath.row]的操作;然后用这些信息推送一个视图控制器,这样它就知道该过滤什么了