Je suis confronté à un problème très stupide avec mon code pour les boutons dans la barre d'outils. J'utilise le code suivant et j'ai déjà les fonctions de gestionnaire d'action dans le code, mais chaque fois que je clique sur les boutons, j'obtiens l'erreur: "- [UIWebView nom_fonction]: sélecteur non reconnu envoyé à l'instance 0x .... "Quelqu'un peut-il m'aider? Merci.problème avec le gestionnaire d'actions de UIBarButtonItems
dans le fichier .h:
- (void) goBackHandler;
- (void) goForwardHandler;
- (void) goSafari;
dans le fichier .m:
UIBarButtonItem *backButton=[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(goBackHandler)]autorelease];
UIBarButtonItem *forwardButton=[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"forward.png"] style:UIBarButtonItemStylePlain target:self.webViews action:@selector(goForwardHandler) ] autorelease];
UIBarButtonItem *safariButton=[[[UIBarButtonItem alloc] initWithTitle:@"Safari" style:UIBarButtonItemStyleBordered target:self action:@selector(goSafari)]autorelease];
UIBarButtonItem *flex=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]autorelease];
NSArray *arrayOfButtons=[[[NSArray alloc] initWithObjects:backButton,flex,safariButton,flex,forwardButton, nil]autorelease];
[self setToolbarItems:arrayOfButtons];
- (void) goBackHandler
{
if ([self.webViews canGoBack])
{
[self.webViews goBack];
}
}
- (void) goForwardHandler
{
if ([self.webViews canGoForward])
{
[self.webViews goForward];
}
}
- (void) goSafari
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[self.webViews stringByEvaluatingJavaScriptFromString:@"window.location"]]];
}