由于原型单元格,编译失败

时间:2014-07-17 08:39:21

标签: xcode uitableview storyboard

我有一个TableViewController子类,其中一个原型单元设计在storyboard中。然后我将引用传递给类头等,由于某种原因它无法编译它。但这种联系似乎很好。我为您提供构建错误和故事板的代码和图片。我正在使用Xcode 4.3.3。任何帮助都非常感谢。

favTable.h

#import <UIKit/UIKit.h>


@interface favTable : UITableViewController  <NSFetchedResultsControllerDelegate> 
{
    NSFetchedResultsController *fetchedResultsController;
   NSManagedObjectContext *managedObjectContext;

    NSArray *favArr;
    NSMutableArray *favName;
    NSMutableArray *favScore;


}

@property (nonatomic, retain) NSArray *favArr;

@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;

@property (nonatomic, strong) NSMutableArray *favName;
@property (nonatomic, strong) NSMutableArray *favScore;

@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;




@property (strong, nonatomic) IBOutlet UITableViewCell *celldes;


@property (strong, nonatomic) IBOutlet UIImageView *cellimage;

@property (strong, nonatomic) IBOutlet UILabel *cellname;

@property (strong, nonatomic) IBOutlet UILabel *cellmanu;


@property (strong, nonatomic) IBOutlet UILabel *cellscore;



@end

favTable.m

#import "favTable.h"
#import "ecoAppDelegate.h"



@interface favTable ()


@end

@implementation favTable

@synthesize favArr;

@synthesize managedObjectContext;
@synthesize fetchedResultsController;
@synthesize favName;
@synthesize favScore;


@synthesize celldes;
@synthesize cellimage;
@synthesize cellname;
@synthesize cellmanu;
@synthesize cellscore;



- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = @"Favorites";


    self.navigationController.navigationBar.translucent = NO;




    // passing the array of addedtofavorites to the total one with all favorites



    self.managedObjectContext = ((ecoAppDelegate *) [UIApplication sharedApplication].delegate).managedObjectContext;



    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription
                                   entityForName:@"FavoritesInfo" inManagedObjectContext:managedObjectContext];
    [fetchRequest setEntity:entity];

    fetchRequest.resultType = NSDictionaryResultType;

    [fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"name", nil]];



      NSError *error=nil;

    self.favArr=[[self.managedObjectContext executeFetchRequest:fetchRequest error:&error]mutableCopy];


    if (error!=nil) {
        NSLog(@" fetchError=%@,details=%@",error,error.userInfo); 
    }


    self.favName = [[self.favArr valueForKey:@"name"] mutableCopy];
    self.favScore = [[self.favArr valueForKey:@"score"] mutableCopy];



}

- (void)viewDidUnload
{
    [self setCelldes:nil];
    [self setCellimage:nil];
    [self setCellname:nil];
    [self setCellmanu:nil];
    [self setCellscore:nil];
    [super viewDidUnload];

}

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

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [favName count];;
}





- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


    static NSString *CellIdentifier = @"Cell";

         // Configure the cell...

    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

cellname.text = @"Test";

    return cell;
}






@end

Storyboard and connections

Build Errors

1 个答案:

答案 0 :(得分:0)

  • 我将IB插座手动移动到一个单独的自定义单元类中,然后将引用链接到故事板(可能会在较新版本中修复)
  • 然后在原型单元格中应用该单元格样式,只使用标识符更改单元格UI项目的内容(不需要标记)