Xcode4 未调用方法CellForRowatineXpath方法

Xcode4 未调用方法CellForRowatineXpath方法,xcode4,xcode5,xcode4.5,Xcode4,Xcode5,Xcode4.5,我是iOS的初学者,我在table view的帮助下创建了一个应用程序。我只是运行我的应用程序,在运行应用程序时,应用程序不会调用cellForRowIndexPath方法。我使用Json作为web服务。在输出屏幕中,将显示解析数据,但它不会在模拟器中显示。我设置了断点,我知道cellForRowIndexPath路径没有被调用。我将数据源和数据委托拖到xib文件的onner文件中。但是什么都没有发生。。。表视图正在显示,但没有内容。。。我完蛋了。。任何人请帮助我 @implementation

我是iOS的初学者,我在table view的帮助下创建了一个应用程序。我只是运行我的应用程序,在运行应用程序时,应用程序不会调用cellForRowIndexPath方法。我使用Json作为web服务。在输出屏幕中,将显示解析数据,但它不会在模拟器中显示。我设置了断点,我知道cellForRowIndexPath路径没有被调用。我将数据源和数据委托拖到xib文件的onner文件中。但是什么都没有发生。。。表视图正在显示,但没有内容。。。我完蛋了。。任何人请帮助我

@implementation MSPackagesController

@synthesize packageTable;
@synthesize packages;
@synthesize mainCtrl;

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


-(void)viewDidLoad
{
    [super viewDidLoad];
}

-(void)parseData    {

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.animationType = MBProgressHUDAnimationFade;
    hud.detailsLabelText = @"Loading...";

    MSJsonParser *parser = [[MSJsonParser alloc]initWithParserType:kPackagesParsing];
    parser._parserSource = self;
    [parser requestParsingWithUrl:PACKAGES_LIST_URL];
}

-(void)sharePackageFromCell:(UIButton*)btn
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.animationType = MBProgressHUDAnimationFade;
    hud.detailsLabelText = @"Loading...";

    NSString *title = [[self.packages objectAtIndex:btn.tag] packageName];
    /*NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:btn.tag] picture]];
     NSData *imgdata = [NSData dataWithContentsOfURL:imgUrl];
     UIImage *image = [UIImage imageWithData:imgdata];*/
   // NSURL *imgUrl = [NSURL URLWithString:[[self.packages objectAtIndex:btn.tag] picture]];
    NSString *desc = [[self.packages objectAtIndex:btn.tag] packageDescription];
    NSString *message = @"Visit GlamZapp in AppStore";

    UIActivityViewController *activityCtrl = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:title,desc,message, nil] applicationActivities:nil];
    activityCtrl.excludedActivityTypes  = @[UIActivityTypePrint,UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypeAssignToContact];

    activityCtrl.completionHandler = ^(NSString *activityType, BOOL completed)
    {
        NSLog(@" activityType: %@", activityType);
        NSLog(@" completed: %i", completed);
    };

    [self.mainCtrl presentViewController:activityCtrl animated:YES completion:^{
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    }];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}





#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    MSPackagesCell *cell = (MSPackagesCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *cells = [[NSBundle mainBundle]loadNibNamed:[Common checkDeviceforController:@"MSPackagesCell"] owner:nil options:nil];
        for (id eachObject in cells) {
            cell = eachObject;
            break;
        }
        //cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    // Configure the cell...
   // NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:indexPath.row]picture]];
    //[cell.promoImg setImageWithURL:imgUrl placeholderImage:[UIImage imageNamed:@"slider_dummy.jpg"] andSize:cell.promoImg.frame.size];
    cell.PackageName.text = [[self.packages objectAtIndex:indexPath.row] packageName];
    cell.PackageDescription.text = [[self.packages objectAtIndex:indexPath.row] packageDescription];

//    NSMutableAttributedString *strikedPrice = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ %@",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ] ];
//    [strikedPrice addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(0, [strikedPrice length])];


    //cell.oldPriceLabel.attributedText = strikedPrice;
    cell.PriceLabel.text = [NSString stringWithFormat:@"%@ %@",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ];

    //[string appendFormat:@"%@\r\n", message];

   // cell.promocodelabel.text = [NSString stringWithFormat:@"Promo code: %@",[[self.packages objectAtIndex:indexPath.row] promoCode]];

    cell.ShareButton.tag = indexPath.row;
    [cell.ShareButton addTarget:self action:@selector(sharePackageFromCell:) forControlEvents:UIControlEventTouchUpInside];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

  //    MSPackageDetailsController *promDet = [[MSPackageDetailsController alloc]initWithNibName:[Common checkDeviceforController:@"MSPackageDetailsController"] bundle:nil];
//    promDet.delegate = self;
//    promDet.offerId = [[self.packages objectAtIndex:indexPath.row] promoId];
//    promDet.title = [[self.packages objectAtIndex:indexPath.row] promoTitle];

  //  [self.delegate didSelectPromotion:promDet];

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}



-(void)foundPackagesData:(NSArray *)packa
{
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    self.packages = packa;
    [self.packageTable reloadData];

}

-(void)connectionFailed
{
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}

在接口(.h)文件中添加UITableViewDataSource、UITableViewDelegate

@接口MSPackagesController:UIViewController

我认为您没有在.h文件中添加UITableviewDataSource和UITableViewDelegate

@interface MSPackagesController : UIViewController <UITableViewDataSource,UITableViewDelegate>