IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Objective-C Discussion :

Master-Detail Application : modifier le détaille


Sujet :

Objective-C

  1. #1
    Membre actif
    Homme Profil pro
    Inscrit en
    Février 2013
    Messages
    604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 604
    Points : 206
    Points
    206
    Par défaut Master-Detail Application : modifier le détaille
    Bonjour,
    J'ai crée une Master-Detail Application
    j'ai crée une classe Tache avec un titre et une priorité. J'ajoute une tache à chaque fois que je clique sur le bouton +.
    Je voudrais savoir comment je peux modifié le detail de l'objet pour avoir nomDeLaTache (priorité: valeurDeLaPriorite), j'ai mis dans la méthode - (void)insertNewObject
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            NSString * detaille = [[NSString alloc] initWithFormat:@"%@ (priorité:%d)",[uneTache titre],[uneTache priorite]];
            self.detailViewController.detailItem = detaille ;
    mais cela ne fonctionne pas

    MasterViewController.m
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
     
    //
    //  MasterViewController.m
    //  projetTableView
    //
    //  Created by ket on 08/03/2015.
    //  Copyright (c) 2015 ket. All rights reserved.
    //
     
    #import "MasterViewController.h"
    #import "DetailViewController.h"
    #import "Tache.h"
     
    @interface MasterViewController ()
     
    @property NSMutableArray *objects;
    @end
     
    @implementation MasterViewController
     
    - (void)awakeFromNib {
        [super awakeFromNib];
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
            self.clearsSelectionOnViewWillAppear = NO;
            self.preferredContentSize = CGSizeMake(320.0, 600.0);
            //self.title = NSLocalizedString(@"Master",@"Taches");
        }
    }
     
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        self.navigationItem.leftBarButtonItem = self.editButtonItem;
     
        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
        self.navigationItem.rightBarButtonItem = addButton;
        self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
     
        self.navigationItem.title = @"Taches";
     
     
    }
     
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
     
    - (void)insertNewObject:(id)sender {
        if (!self.objects) {
            self.objects = [[NSMutableArray alloc] init];
        }
     
        Tache* uneTache = [[Tache alloc] initWithTitre:@"A faire" Andpriorite:0];
        [self.objects insertObject:uneTache atIndex:0];
     
     
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
        [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
     
     
        NSString * detaille = [[NSString alloc] initWithFormat:@"%@ (priorité:%d)",[uneTache titre],[uneTache priorite]];
        self.detailViewController.detailItem = detaille ;
     
     
    }
     
    #pragma mark - Segues
     
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([[segue identifier] isEqualToString:@"showDetail"]) {
            NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
            NSString * object = self.objects[indexPath.row];
            DetailViewController *controller = (DetailViewController *)[[segue destinationViewController] topViewController];
            [controller setDetailItem:object];
            controller.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
            controller.navigationItem.leftItemsSupplementBackButton = YES;
        }
    }
     
    #pragma mark - Table View
     
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    }
     
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return self.objects.count;
    }
     
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
     
        NSDate *object = self.objects[indexPath.row];
        cell.textLabel.text = [object description];
        return cell;
    }
     
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
        // Return NO if you do not want the specified item to be editable.
        return YES;
    }
     
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            [self.objects removeObjectAtIndex:indexPath.row];
            [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        } else if (editingStyle == UITableViewCellEditingStyleInsert) {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
        }
    }
     
     
     
    @end

  2. #2
    Membre éclairé
    Avatar de LeBzul
    Homme Profil pro
    Inscrit en
    Décembre 2008
    Messages
    381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 381
    Points : 832
    Points
    832
    Par défaut
    Salut,
    Il y a pleins de tuto qui traine sur internet très bien fait :
    http://www.appcoda.com/ios-programmi...able-view-app/

    En espérant que ca t'aide.
    "Quand la lune n'est pas là, la nuit mène une existence obscure"

  3. #3
    Membre actif
    Homme Profil pro
    Inscrit en
    Février 2013
    Messages
    604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 604
    Points : 206
    Points
    206
    Par défaut
    ok merci de votre aide

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [objectif-C] master-detail application : section
    Par pitchu dans le forum Objective-C
    Réponses: 1
    Dernier message: 16/03/2015, 12h54
  2. [Tomahawk] [dataTable] Master detail
    Par infonini dans le forum JSF
    Réponses: 3
    Dernier message: 06/09/2007, 11h42
  3. master detail -dbLookupComboBox
    Par atb dans le forum Bases de données
    Réponses: 1
    Dernier message: 10/04/2007, 18h23
  4. [Débutant]Application à modifier
    Par Labour dans le forum Langage
    Réponses: 7
    Dernier message: 05/04/2007, 14h26
  5. [Forms] Debugger/Pb canevas-relation Master/detail
    Par lafouine dans le forum Forms
    Réponses: 16
    Dernier message: 12/08/2005, 18h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo