SwiftypeTouch 是一个库,它使您能够轻松地将 Swiftype 驱动的搜索 添加到您的 iOS 应用程序中。
git clone [email protected]:swiftype/SwiftypeTouch.git
) 并将顶级 SwiftypeTouch
目录复制到包含 YourProject.xcodeproj
的目录中(或使用 git submodule)。SwiftypeTouch/SwiftypeTouch.xcodeproj
添加到您的 Xcode 项目中。SwiftypeTouch.xcodeproj
拖放到项目浏览器中完成。YourProject.xcodeproj
中 Build Settings 中,将以下内容添加到您的 HEADER_SEARCH_PATHS
中:$(SRCROOT)/SwiftypeTouch/
。-ObjC
和 -all_load
添加到项目的 OTHER_LDFLAGS
中。libSwiftypeTouch.a
链接到您的目标上。在目标设置下,转到 Build Phases,展开 "Link Binary With Libraries",点击 "+" 按钮,并从对话框中选择 libSwiftypeTouch.a
。现在,您可以在项目中使用 SwiftypeTouch 了。
如果您使用 Swiftype 爬虫创建了 Swiftype 搜索引擎,您可以按照以下步骤快速添加显示在表格视图中的搜索。选择结果将在 webview 中加载。
#import <SwiftypeTouch/STPageDocumentTypeResultsObject.h>
添加到将搜索栏显示在屏幕上的视图控制器实现中。在您的视图控制器中创建一个名为 resultObject
的私有属性,类型为 STPageDocumentTypeResultsObject
。
@property (nonatomic, strong) STPageDocumentTypeResultsObject *resultObject;
在视图控制器的 viewDidLoad
中添加以下代码以使搜索栏出现:
self.resultObject = [[STPageDocumentTypeResultsObject alloc] initWithViewController:self clientEngineKey:@"yourEngineKey"];
[self.view addSubview:self.resultObject.searchBar];
要查看此示例,请查看 SwiftypeTouchExample 应用程序 的源代码。
此代码根据 MIT 许可证提供。有关详细信息,请参阅 LICENSE.txt。