Cacher le clavier lorsque défilement UITableView

Dans mon application je veux cacher le clavier quand je commence à défiler UITableView. Je recherche à ce sujet dans internet, et plus la réponse est sous-classement UITableView (http://stackoverflow.com/questions/3499810/tapping-a-uiscrollview-to-hide-the-keyboard).

J'ai fait sous-classe, mais il ne faut pas travailler.

#import <UIKit/UIKit.h>

@protocol MyUITableViewDelegate <NSObject>
@optional
- (void)myUITableViewTouchesBegan;
@end

@interface MyUITableView : UITableView <UITableViewDelegate, UIScrollViewDelegate> {
    id<MyUITableViewDelegate> delegate;
}
@end

.m fichier

#import "MyUITableView.h"

@implementation MyUITableView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"delegate scrollView"); //this is dont'work
    [super scrollViewDidScroll:scrollView];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"delegate myUITableViewTouchesBegan"); //work only here
    [delegate myUITableViewTouchesBegan];
    [super touchesBegan:touches withEvent:event];

}

- (void)dealloc {
...

- Je utiliser cette classe comme ça. Mais la fonction de délégué myUITableViewTouchesBegan ne fonctionnent pas dans le ViewController

.h

#import <UIKit/UIKit.h>
#import "MyUITableView.h"

@interface FirstViewController : UIViewController <UITableViewDelegate, UISearchBarDelegate, MyUITableViewDelegate> {
    MyUITableView *myTableView;
    UISearchBar *searchBar; 
}

@property(nonatomic,retain) IBOutlet MyUITableView *myTableView;
...

.m

- (void) myUITableViewTouchesBegan{
    NSLog(@"myUITableViewTouchesBegan");
    [searchBar resignFirstResponder];
}

J'ai quelques problèmes avec cette mise en oeuvre:

1) myUITableViewTouchesBegan ne fonctionnent pas dans le ViewController

2) NSLog de MyUITableView.m - NSLog(@"délégué myUITableViewTouchesBegan"); ne fonctionnent que lorsque je touche la table. Comment fait c'est du travail aussi quand je commence à défiler?

J'ai essayer de remplacer scrollViewDidScroll mais comiler dit que MyUITableVIew peut-être de ne pas répondre sur cette chaîne [super scrollViewDidScroll:le scrollView];

InformationsquelleAutor olegi | 2010-12-09