Partage
  • Partager sur Facebook
  • Partager sur Twitter

[iOS] UISlider

Sujet résolu
Anonyme
    13 août 2012 à 12:45:19

    Bonjour,

    j'aimerais, à l'aide d'un UISlider, pouvoir zoomer sur une carte.

    .h

    #import <UIKit/UIKit.h>
    #import <MapKit/MapKit.h>
    
    @interface ViewController : UIViewController
    @property (weak, nonatomic) IBOutlet MKMapView *mapView;
    @property (weak, nonatomic) IBOutlet UISlider *slider;
    - (IBAction)slider:(id)sender;
    
    @end
    


    .m

    - (IBAction)slider:(id)sender {
        if ( slider.value == 0 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 10000000, 10000000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 1 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 5000000, 5000000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 2 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 1000000, 1000000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 3 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 500000, 500000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 4 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 100000, 100000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 5 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 50000, 50000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 6 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 10000, 10000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 7 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 5000, 5000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 8 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 1000, 1000);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 9 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 500, 500);
            [mapView setRegion:region animated:TRUE];
        }
        else if ( slider.value == 10 ) {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(
            mapView.userLocation.location.coordinate, 100, 100);
            [mapView setRegion:region animated:TRUE];
        }
    }
    @end
    


    J'ai déjà réussi à faire fonctionne ce système avec un UIStepper, mais j'aimerais le faire avec un UISlider.

    Le problème est donc que j'ai beau modifié la valeur du slider, il n'y a aucun zoom, SAUF aux extrémités..

    Merci d'avance pour vos réponses
    • Partager sur Facebook
    • Partager sur Twitter

    [iOS] UISlider

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown