我將UISearchBar拖到我的xib上,將它掛接到我的文件的所有者,委託和searchBar作爲插座。使用搜索欄切換到視圖時出現崩潰。我不知道我在做什麼錯,我是否需要在停止崩潰之前實施搜索欄委託方法?當試圖實現UISearchBar時,程序崩潰時出現NSException
#import <UIKit/UIKit.h>
@interface ThirdViewController : UIViewController {
@private UISearchBar *searchBar_;
}
@property (nonatomic, retain) IBOutlet UISearchBar *searchBar;
@end
#import "ThirdViewController.h"
@implementation ThirdViewController
@synthesize
searchBar = searchBar_;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[searchBar_ release], searchBar_ = nil;
[super dealloc];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.searchBar resignFirstResponder];
}
@end
你可以添加崩潰日誌嗎? 'dealloc'方法沒有錯。 –