1
votes

I know the question has already been asked and answered but I cant find the solution.

I've got this error even if I'm not pushing the incriminated view controller :

Unbalanced calls to begin/end appearance transitions for .

here is my code NewsViewController.m

#import "NewsViewController.h"
#import "XMLToObjectParser.h"
#import "UneNews.h"

#define USE_CUSTOM_DRAWING 1

@interface NewsViewController ()

@end

@implementation NewsViewController 
@synthesize imageView;
@synthesize vueDetail;

@synthesize tableauNews,tableViewFluxRSS;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil tableauDeNews:(NSMutableArray *)tableauDeNews
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

        //récupération du tableau de news initialisé
        tableauNews = tableauDeNews;
    }
    return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    tableViewFluxRSS.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableViewFluxRSS.rowHeight = 143;
    tableViewFluxRSS.backgroundColor = [UIColor clearColor];

}

- (void)viewDidUnload
{
    [self setImageView:nil];
    [self setVueDetail:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return NO;
}


//Navigation

- (IBAction)goHome:(id)sender{
    [self.navigationController popToRootViewControllerAnimated:YES];    
}

// Override to support row selection in the table view.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here -- for example, create and push another view controller.
    [vueDetail loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[[tableauNews objectAtIndex:indexPath.row] detail]]]];

}


//gestion du UITableView 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [tableauNews count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


    const NSInteger TOP_LABEL_TAG = 1001;
    const NSInteger BOTTOM_LABEL_TAG = 1002;
    const NSInteger DATE_LABEL_TAG = 1003;
    const NSInteger ANNEE_LABEL_TAG = 1004;
    UILabel *topLabel;
    UILabel *bottomLabel;
    UILabel *dateLabel;
    UILabel *anneeLabel;
    UILabel *enSavoirPlus;

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableViewFluxRSS dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        //
        // Create the cell.
        //
        cell = [[UITableViewCell alloc] 
                 initWithStyle:UITableViewCellStyleDefault 
                                       reuseIdentifier:CellIdentifier];

        //
        // Configure the properties for the text that are the same on every row
        //
            dateLabel = [[UILabel alloc]
         initWithFrame:
         CGRectMake(6,46,75,57)];

        dateLabel.tag = DATE_LABEL_TAG;
        dateLabel.backgroundColor = [UIColor clearColor];
        dateLabel.textColor = [UIColor whiteColor];
        dateLabel.font = [UIFont systemFontOfSize:28];
        [cell.contentView addSubview:dateLabel];
        //
        // Configure the properties for the text that are the same on every row
        //
        anneeLabel = [[UILabel alloc]
                     initWithFrame:
                     CGRectMake(6,100,70,57)];

        anneeLabel.tag = DATE_LABEL_TAG;
        anneeLabel.backgroundColor = [UIColor clearColor];
        anneeLabel.textColor = [UIColor whiteColor];
        anneeLabel.font = [UIFont systemFontOfSize:31];
        [cell.contentView addSubview:anneeLabel];

        topLabel =
        [[UILabel alloc]
         initWithFrame:
         CGRectMake(94,5,325,20)];

        [cell.contentView addSubview:topLabel];

        //
        // Configure the properties for the text that are the same on every row
        //
        topLabel.tag = TOP_LABEL_TAG;
        topLabel.backgroundColor = [UIColor clearColor];
        topLabel.textColor = [UIColor whiteColor];
        topLabel.font = [UIFont systemFontOfSize:18];


        //
        // Configure the properties for the text that are the same on every row
        //
        bottomLabel =
        [[UILabel alloc]
         initWithFrame:
         CGRectMake(94,30,325,80)];

        bottomLabel.tag = BOTTOM_LABEL_TAG;
        bottomLabel.backgroundColor = [UIColor clearColor];
        bottomLabel.textColor = [UIColor whiteColor];
        bottomLabel.font = [UIFont systemFontOfSize:18];
        [bottomLabel setLineBreakMode:UILineBreakModeWordWrap];
        [bottomLabel setNumberOfLines:0];

        [cell.contentView addSubview:bottomLabel];

        //
        // Create a background image view.
        //
        cell.backgroundView =
        [[UIImageView alloc] init];
        cell.selectedBackgroundView =
        [[UIImageView alloc] init];

        enSavoirPlus =
        [[UILabel alloc]
         initWithFrame:
         CGRectMake(260,121,200,20)];

        [cell.contentView addSubview:enSavoirPlus];

        //
        // Configure the properties for the text that are the same on every row
        //
        enSavoirPlus.tag = TOP_LABEL_TAG;
        enSavoirPlus.backgroundColor = [UIColor clearColor];
        enSavoirPlus.textColor = [UIColor yellowColor];
        //topLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
        enSavoirPlus.font = [UIFont systemFontOfSize:18];
    }

    else
    {
        topLabel = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG];
        bottomLabel = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG];
        dateLabel = (UILabel *)[cell viewWithTag:DATE_LABEL_TAG];
        anneeLabel = (UILabel *)[cell viewWithTag:ANNEE_LABEL_TAG];

    }

    topLabel.text = [[tableauNews objectAtIndex:indexPath.row] titre];
    bottomLabel.text = [[tableauNews objectAtIndex:indexPath.row] contenu];
    [bottomLabel sizeToFit];
    dateLabel.text = [[tableauNews objectAtIndex:indexPath.row] dateDeParution];
    anneeLabel.text = [[tableauNews objectAtIndex:indexPath.row] annee];
    enSavoirPlus.text = @"En savoir plus...";

    //
    // Set the background and selected background images for the text.
    // Since we will round the corners at the top and bottom of sections, we
    // need to conditionally choose the images based on the row index and the
    // number of rows in the section.
    //
    UIImage *rowBackground;

        rowBackground = [UIImage imageNamed:@"fd-textes-news.png"];
        //selectionBackground = [UIImage imageNamed:@"middleRowSelected.png"];

    ((UIImageView *)cell.backgroundView).image = rowBackground;
    //((UIImageView *)cell.selectedBackgroundView).image = selectionBackground;


    return cell;
}


//fin gestion UITableView


@end

I think my problem may be due to my implementation of the init - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil tableauDeNews:(NSMutableArray *)tableauDeNews;

need help thx

1
ok I've got a clue, initWithNibName of the NewsViewController seems to called by other viewControllers but I cont find trace of NewsViewController in themAbzamon

1 Answers

0
votes

I found the problem:

To create my buttons I copy paste them in the interfaceBuilder, the copied buttons have kept their old actions, and I had a new IBAction.

My copied buttons had 2 IBactions (one calling a NewsViewController and another calling the right viewController). The message was poping each time I clicked the copied button.

So check your buttons in the interface Builder, "Unbalanced calls to begin/end appearance transitions" can be caused by buttons having two IBActions, conflictual (eg. pushing two different viewControllers at the same time).