Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 同样,对开始/结束外观转换的不平衡调用_Objective C_Xcode_Uiviewcontroller - Fatal编程技术网

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

Objective c 同样,对开始/结束外观转换的不平衡调用,objective-c,xcode,uiviewcontroller,Objective C,Xcode,Uiviewcontroller,我知道这个问题已经被问到和回答了,但我找不到解决办法 即使我没有按下有罪的视图控制器,也会出现此错误: 开始/结束外观转换的调用不平衡 这是我的代码NewsViewController.m #import "NewsViewController.h" #import "XMLToObjectParser.h" #import "UneNews.h" #define USE_CUSTOM_DRAWING 1 @interface NewsViewController () @end @im

我知道这个问题已经被问到和回答了,但我找不到解决办法

即使我没有按下有罪的视图控制器,也会出现此错误:

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

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

我发现了问题:

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

我复制的按钮有两个iAction(一个调用NewsViewController,另一个调用right viewController)。 每次单击“复制”按钮时,消息都会弹出


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

好的,我有一个线索,NewsViewController的initWithNibName似乎被其他ViewController调用,但我继续在其中找到NewsViewController的踪迹