0
我的代碼如下: -如何在UISearchbar處於活動狀態時進行放大和縮小?
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
self.navigationController.navigationBar.hidden = TRUE;
_r = self.view.frame;
_r.origin.y = -44;
_r.size.height += 44;
self.view.frame = _r;
[searchBar setShowsCancelButton:YES animated:YES];
return YES;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar
{
NSLog(@"cancel button pressed");
//This'll Hide The cancelButton with Animation
[searchBar setShowsCancelButton:NO animated:YES];
_r.origin.y = 44;
_r.size.height -= 44;
self.view.frame = _r;
[searchBar resignFirstResponder];
//remaining Code'll go here
}
上面的代碼並沒有像預期的那樣。它破壞了視圖,而不是放大和縮小。當按下「取消」按鈕時,它變成下圖所示。我如何在iPhone的「設置」中擁有完美的放大和縮小效果,例如Apple的搜索欄。 Spoiled view