我有一個應用程序中的錯誤,我正在處理有關UISearchBar。UISearchBar在景觀沒有響應,但在iPad上的肖像罰款
使用代碼:
int width = 250;
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(768 - width - indent, companySelectionButton.frame.origin.y + (companySelectionButton.frame.size.height - 44)/2, width, 44)];
[searchBar setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin];
[searchBar setPlaceholder:[Globals localisedString:@"Search by Code or Name"]];
[searchBar setAutocorrectionType:UITextAutocorrectionTypeNo];
[searchBar setDelegate:self];
[self.view addSubview:searchBar];
[searchBar release];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
搜索欄是我想在兩個方向的位置,但它不會迴應水龍頭景觀,併成爲第一個響應者/顯示鍵盤。
我試着註釋掉以下行來看看是否有幫助,但它並沒有解決它:
[searchBar setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
任何人也有類似的問題?
感謝提前:)
EDIT
註釋掉[搜索欄setDelegate:無]之後;搜索欄能夠成爲所有方向的第一響應者。但我當然需要一個委託才能使用搜索欄!有任何想法嗎???會繼續玩,也許我錯過了一些委託方法?
謝謝,但這並沒有幫助 – Marky 2011-05-16 12:24:27
你可以告訴改變搜索欄的幀大小發生了什麼?/? – 2011-05-16 12:34:23
更改搜索欄的框架大小應該工作 – 2011-05-16 12:34:48