同样,不平衡调用开始/结束外观转换

时间:2012-07-12 01:15:46

标签: objective-c xcode uiviewcontroller

我知道问题已经被提出并得到了解答,但我找不到解决方案。

即使我没有推动有罪的视图控制器,我也遇到了这个错误:

对于开始/结束外观转换的不平衡调用。

这是我的代码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

我认为我的问题可能是由于我执行了init - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil tableauDeNews:(NSMutableArray *)tableauDeNews;

需要帮助 thx

1 个答案:

答案 0 :(得分:0)

我发现了问题:

要创建我的按钮,我将它们复制粘贴到interfaceBuilder中, 复制的按钮保留了旧的动作,我有一个新的IBAction。

我复制的按钮有2个IBactions(一个调用NewsViewController,另一个调用右侧viewController)。 每次单击复制的按钮时都会弹出消息。

因此,检查界面生成器中的按钮,“开始/结束外观转换的不平衡调用”可能是由具有两个IBAction,冲突的按钮引起的(例如,同时推送两个不同的viewControllers )。