le problème vient peut être du fait que dans mon storyboard ma segue "pointe" un navigation controller et non directement sur la vue qui m'intéresse ?
sinon voici le code de ma classe "TacheViewController.h" :
#import <UIKit/UIKit.h>
#import "CreationTacheViewController.h"
#import "Projet.h"
#import "Tache.h"
@interface TacheViewController : UITableViewController <CreateTacheDelegate>
@property (strong, nonatomic) Projet *projet;
@property (strong, nonatomic) CreationTacheViewController *creationTacheViewController;
@property (strong, nonatomic) NSMutableArray *tacheArray;
@end
[---]
le code de la classe "TacheViewController.m" :
#import "TacheViewController.h"
#import "CreationTacheViewController.h"
@interface TacheViewController ()
@end
@implementation TacheViewController
@synthesize projet = _projet;
@synthesize tacheArray = _tacheArray;
@synthesize creationTacheViewController = _creationTacheViewController;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//mettre le titre
self.title = _projet.titre;
//initialisation du tableau à partir des taches du projet
_tacheArray = [[NSMutableArray alloc] initWithArray:[_projet.tache allObjects]];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown && interfaceOrientation != UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _tacheArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TacheCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell ==nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Tache *laTache = (Tache *)[_tacheArray objectAtIndex:indexPath.row];
cell.textLabel.text = laTache.titre;
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[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
}
}
*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"creationTache"])
{
_creationTacheViewController = [[CreationTacheViewController alloc] initWithDelegate:self];
// _creationTacheViewController.delegate = self;
}
}
/*- (void)viewWillAppear:(BOOL)animated
{
[self.tableView reloadData];
}*/
- (void)createTacheController:(CreationTacheViewController *)controller didCreateTache:(Tache *)tache
{
tache.projet = _projet;
[_projet.managedObjectContext save:nil];
[_tacheArray addObject:tache];
[self.tableView reloadData];
}
@end[---]
le code de la classe "CreationTacheViewController.h" :
#import <UIKit/UIKit.h>
#import "Tache.h"
#import "Projet.h"
@class Tache;
@class CreationTacheViewController;
@protocol CreateTacheDelegate <NSObject>
- (void)createTacheController:(CreationTacheViewController *)controller didCreateTache:(Tache *)tache;
@end
@interface CreationTacheViewController : UIViewController <UITextViewDelegate>
@property (nonatomic, retain) id <CreateTacheDelegate> delegate;
@property (strong, nonatomic) IBOutlet UITextField *titreTache;
@property (strong, nonatomic) IBOutlet UIDatePicker *dateDebut;
@property (strong, nonatomic) IBOutlet UIDatePicker *dateFin;
@property (strong, nonatomic) IBOutlet UITextView *descriptionTache;
- (IBAction)creerTache:(id)sender;
- (IBAction)cancel:(id)sender;
- (IBAction)titreReturn:(id)sender;
- (id)initWithDelegate:(id)delegate;
@end
[---]
et enfin le code de la classe "CreationTacheViewController.m" :
#import "CreationTacheViewController.h"
#import "AppDelegate.h"
@interface CreationTacheViewController ()
@end
@implementation CreationTacheViewController
@synthesize titreTache;
@synthesize dateDebut;
@synthesize dateFin;
@synthesize descriptionTache;
@synthesize delegate = _delegate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
descriptionTache.delegate = self;
self.title = @"Création d'une tâche";
}
- (void)viewDidUnload
{
[self setTitreTache:nil];
[self setDateDebut:nil];
[self setDateFin:nil];
[self setDescriptionTache:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown && interfaceOrientation != UIInterfaceOrientationPortrait);
}
- (IBAction)creerTache:(id)sender
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if ([titreTache.text isEqualToString:@""])
{
UIAlertView *alertTitre = [[UIAlertView alloc] initWithTitle:@"Titre" message:@"Titre de la tâche non renseigné" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertTitre setAlertViewStyle:UIAlertViewStyleDefault];
[alertTitre show];
}else if (dateDebut.date > dateFin.date)
{
UIAlertView *alertDate = [[UIAlertView alloc] initWithTitle:@"Date" message:@"La date de fin doit être supérieur à la date de début" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertDate setAlertViewStyle:UIAlertViewStyleDefault];
[alertDate show];
}else if ([descriptionTache.text isEqualToString:@""])
{
UIAlertView *alertDescription = [[UIAlertView alloc] initWithTitle:@"Date" message:@"Description de la tache non renseigné" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertDescription setAlertViewStyle:UIAlertViewStyleDefault];
[alertDescription show];
}else
{
//Créer un nouveau projet ou une nouvelle tache
Tache *tache = (Tache *)[NSEntityDescription insertNewObjectForEntityForName:@"Tache" inManagedObjectContext:appDelegate.managedObjectContext];
tache.titre = titreTache.text;
tache.dateDebut = dateDebut.date;
tache.dateFin = dateFin.date;
tache.descritption = descriptionTache.text;
tache.realisee = NO;
NSError *error = nil;
if (![appDelegate.managedObjectContext save:&error])
{
//gérer l'erreur
}
[self.delegate createTacheController:self didCreateTache:tache];
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
}
- (IBAction)cancel:(id)sender
{
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
- (IBAction)titreReturn:(id)sender
{
[sender resignFirstResponder];
}
- (void)textViewDidBeginEditing:(UITextView *)textView
{
if (textView == descriptionTache)
{
//on anime le retour de la vue
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
//on déplace la vue vers le haut
self.view.transform = CGAffineTransformMakeTranslation(0.0, -300);
[UIView commitAnimations];
}
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
if (textView == descriptionTache)
{
// on déplace la vue en même temps que le clavier pour qu’il ne cache pas le text field
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
// on remet la vue à son état initial
self.view.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if ([text isEqualToString:@"\n"])
{
[textView resignFirstResponder];
}
return YES;
}
- (id)initWithDelegate:(id)p_delegate
{
self = [super init];
if( self )
{
self.delegate = p_delegate;
}
return self;
}
@endvoila en espérant que cela puisse aider a trouver le problème

(en espérant que ce soit encore plus claire et que ça aide a trouver la problème plus facilement

)
Ce message a été modifié par BenArko - 01 octobre 2012 - 23:16.