小编use*_*663的帖子

无法将searchBar设置为firstResponder

我有一个searchBar我在tableviewcontroller中设置.我引用了这个类似的问题UISearchBar在UITableView重新出现之后无法成为第一响应者,但仍然无法将其设置为第一响应者.在.h文件中:

@property (strong, nonatomic) UISearchController *searchController;
@property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
Run Code Online (Sandbox Code Playgroud)

在视图didload中:

self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;

self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);
self.tableView.tableHeaderView = self.searchController.searchBar;
Run Code Online (Sandbox Code Playgroud)

并在viewDidAppear:

-(void)viewDidAppear:(BOOL)animated {
  [self.searchController setActive:YES];
  [self.searchController.searchBar becomeFirstResponder];
  [super viewDidAppear:animated];
}
Run Code Online (Sandbox Code Playgroud)

当我转向视图时,searchBar会动画,但不会出现键盘.

objective-c uisearchbar first-responder ios uisearchcontroller

44
推荐指数
10
解决办法
3万
查看次数

CloudKit:"内部错误"(1/4000); "无法获得签名证书">

我在模拟器上运行,应用程序工作正常,但一旦在iPhone设备上它崩溃 - 在discoverUserInfo ::发生错误::

discoverUserInfo是从下面Apple的CloudKit示例代码中复制的代码.这是苹果公司的结果,还是我的?

- (void)discoverUserInfo:(void (^)(CKDiscoveredUserInfo *user))completionHandler {

    [self.container fetchUserRecordIDWithCompletionHandler:^(CKRecordID *recordID, NSError *error) {

        if (error) {
            [self showAlert];
            // In your app, handle this error in an awe-inspiring way.
            NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), error);
            //abort();
        } else {
            [self.container discoverUserInfoWithUserRecordID:recordID
                                           completionHandler:^(CKDiscoveredUserInfo *user, NSError *error) {
                                               if (error) {
                                                   [self showAlert];
                                                   // In your app, handle this error deftly.
                                                   NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), error);
                                                   //abort();
                                               } else {
                                                   dispatch_async(dispatch_get_main_queue(), ^(void){
                                                       completionHandler(user);
                                                   }); …
Run Code Online (Sandbox Code Playgroud)

ios cloudkit

34
推荐指数
1
解决办法
827
查看次数