Comment répondre à un utilisateur en appuyant sur un UISegment? Y a-t-il un délégué, ou dois-je programmer (ou Interface Builder), attacher les sélecteurs?Comment répondre à un utilisateur en appuyant sur un UISegment?
0
A
Répondre
0
UISegmentedControl sous-classe UIControl et envoie l'événement de contrôle UIControlEventValueChanged
chaque fois que le segment sélectionné change. Vous pouvez ajouter une paire cible/action pour cet événement dans le code, ou vous pouvez le faire avec le contrôle-cliquer-glisser normal dans IB.
1
Si vous préférez le faire dans le code que vous pouvez utiliser:
[segmentedControl addTarget:self action:@selector(didSelectIndex:) forControlEvents:UIControlEventValueChanged];
, ce qui est alors la méthode qui serait appelé
- (void) didSelectIndex: (id) sender
{
NSLog(@"%@",[(UISegmentedControl *)sender titleForSegmentAtIndex:[(UISegmentedControl *)sender selectedSegmentIndex]]); //replace this with your code
}
Si vous préférez utiliser IB, faites un clic droit sur Votre UISegmentedControl sélectionne Value Changed
puis l'attache à la méthode désirée dans votre premier répondeur.
Questions connexes
- 1. Initialiser un contrôle UISegment
- 2. Comment répondre par programme à un appel
- 3. Comment charger un autre xib en appuyant sur un bouton
- 4. En appuyant sur un bouton, UIScrollView scorll
- 5. Répondre à un message
- 6. Comment fermer un formulaire en appuyant sur la touche d'échappement?
- 7. Comment accéder à un div en appuyant sur tab en utilisant javascript?
- 8. Comment puis-je envoyer un événement clavier à l'application en appuyant sur un bouton?
- 9. En appuyant sur un bouton dans Visual Basic
- 10. La soumission d'un formulaire sur un contrôle utilisateur en appuyant sur Entrée dans un champ de texte ne fonctionne pas
- 11. Comment faire attendre un programme en appuyant sur un bouton en Java
- 12. Modifier l'attribut d'un cadre en appuyant sur un bouton
- 13. Par programmation en appuyant sur un bouton UITabBar dans Xcode
- 14. basculer UIButton-état en appuyant sur, comme un commutateur
- 15. Comment puis-je autoriser un utilisateur à répondre à des dates antérieures à 1970 dans un widget JQuery UI DatePicker?
- 16. Comment composer un numéro en appuyant sur un bouton d'appel dans une application iPhone?
- 17. Répondre à un événement WPF Click dans un contrôle utilisateur lié aux données
- 18. Comment définir un champ Utilisateur sur un SystemUserId en JavaScript?
- 19. Comment envoyer un utilisateur à un URI sur MouseLeftButtonUp?
- 20. En appuyant sur une touche dans C#
- 21. comment mettre l'accent sur un bouton en appuyant sur la touche "Entrée" dans le clavier
- 22. Comment pouvez-vous ouvrir le programme Windows en appuyant sur un bouton sur la page Web
- 23. Répondre à un client de socket spécifique
- 24. jquery/javascript poste à une nouvelle fenêtre en appuyant sur un aperçu bouton
- 25. Iphone - comment répondre par programme à un appel
- 26. Pousser la scène en appuyant sur l'image
- 27. Autoriser l'utilisateur à sélectionner une ligne UIPickerView en appuyant sur
- 28. Javascript - Comment capturer et répondre à un message?
- 29. Comment puis-je envoyer plusieurs images dans un serveur en appuyant sur le programme Perl CGI?
- 30. Comment arrêter l'expansion d'un arbre SWT infini en appuyant sur "*"