UISearchBar仅在UIAlertView节目之后才能工作

时间:2013-01-03 14:20:39

标签: objective-c ios

我的应用程序中有一个搜索栏,但它只能在alertViewShow之后运行(显示我的数字)。我已经实现了代理中的所有方法:shouldChangeTextInRangesearchBarShouldEndEditingsearchBarShouldBeginEditing

状态栏没问题......对于出了什么问题有什么想法吗?

  -(IBAction)btnSearchClick:(id)sender {
      if (!searchBarVisivel) {
          [searchBar setHidden:NO];
          searchBarVisivel = YES;
    }
    else
    {
        searchBarVisivel = NO;
        [searchBar setHidden:YES];
        [searchBar resignFirstResponder];
    }
}

//搜索栏出现,当我触摸搜索栏的文本字段时,键盘出现,但是当我数字...没有...

当我调用其他提醒消息的事件时......搜索栏会在...之后工作。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                 message:@"Alert message"
                                                delegate:self
                                       cancelButtonTitle:@"Não"
                                       otherButtonTitles:@"Sim",nil];
[alert show];

1 个答案:

答案 0 :(得分:0)

我在appDelegate错过了以下代码, applicationDidFinishLauching

 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];

现在SearchBar工作正常!