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'メソッドには何も問題はありません。 –