Partage
  • Partager sur Facebook
  • Partager sur Twitter

[iOS] 2 pickerView sur la même vue

Sujet résolu
    22 avril 2013 à 12:04:33

    Bonjour à tous,

    Je suis actuellement en train de coder une application sur Ipad. Sur une de mes vues j'ai besoin d'avoir 2 pickerView. J'ai suivi plusieurs tutos sur internet mais je n'ai jamais de résultats.

    Voilà mon problème : j'ai un pickerView qui affiche bien toutes les données de la liste que j'ai défini mais pas le second, il ne réagit pas du tout...

    Voila le code de ma page :

    .h

    #import <UIKit/UIKit.h>
    
    @interface ViewWallController : UIViewController{
    
        // liste des informations
        NSMutableArray *materialList;
        NSMutableArray *deflectionMaterialList;
    
        //pickerview
        IBOutlet UIPickerView *materialPV;
        IBOutlet UIPickerView *deflectionMaterialPV;
    }
    
    
    @end

    .m

    #import "ViewWallController.h"
    
    @interface ViewWallController ()
    
    @end
    
    @implementation ViewWallController
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    	// Do any additional setup after loading the view.
        
        materialList = [[NSMutableArray alloc] init];
        [materialList addObject:@"test"];
        
        deflectionMaterialList = [[NSMutableArray alloc] init];
        [deflectionMaterialList addObject:@"Deflection Material"];
        
        NSLog(@"tst");
        
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
    
    // ici a 2 pour voir si le deuxième picker view reagit
        return 2;
    }
    
    
    - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
       
        if ( thePickerView ==materialPV) {
            return [materialList count];
        }
        else if (thePickerView==deflectionMaterialPV)
            return [deflectionMaterialList count];
    
        return 0;
    }
    - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
        
        if ( thePickerView == materialPV)
            return [materialList objectAtIndex:row];
        else if (thePickerView==deflectionMaterialPV)
            return [deflectionMaterialList objectAtIndex:row];
        
        return @"fail";
    }
    
    @end
    


    Alors mon pickerview material affiche ce que j'ai besoin mais pas le pickerview deflectionmaterialPV...

    Merci a tous

    tbille

    -
    Edité par tbille 23 avril 2013 à 16:17:41

    • Partager sur Facebook
    • Partager sur Twitter
      24 avril 2013 à 0:56:36

      Pourquoi tu n'utilises pas Interface Builder pour en mettre deux sur une même vue ?

      Ooops j'ai parlé avant d'avoir lu, dsl..

      -
      Edité par Coolsinus 24 avril 2013 à 0:57:26

      • Partager sur Facebook
      • Partager sur Twitter
        24 avril 2013 à 17:22:14

        Problème résolu

        J'avais juste oublié de mettre :

        materialPV.delegate=self;
        deflectionMaterialPV.delegate=self;


        Merci quand même

        tbille

        • Partager sur Facebook
        • Partager sur Twitter

        [iOS] 2 pickerView sur la même vue

        × 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