Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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
Ios 将值设置为表行的textlabel会多次显示相同的值_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 将值设置为表行的textlabel会多次显示相同的值

Ios 将值设置为表行的textlabel会多次显示相同的值,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我在viewDidLoad方法中从核心数据获取记录,如下所示 NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"PendingShipmentDetails"]; NSEntityDescription *entity = [NSEntityDescription

我在
viewDidLoad
方法中从核心数据获取记录,如下所示

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"PendingShipmentDetails"];


    NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];


    NSArray *result = [self.managedObjectContext executeFetchRequest:request error:&error];


    if (result.count > 0) {
        int i;
        for (i = 0; i < [result count]; i++) {
            NSManagedObject *pending = (NSManagedObject *)[result objectAtIndex:i];

            statusArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"invoice_no"], nil];
            amountArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"amount"], nil];
        }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

}

问题是,
productAmountTextLabel
UITableView
的第一行和第二行中都具有相同的值。我怎样才能纠正它

以下是我的全部代码

- (void)viewDidLoad
{
    //    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    //
    //    [self.navigationController.navigationBar.topItem setTitle:@"Shipment Tracking System"];

    NSArray *titles = [NSArray arrayWithObjects:@"Pending",@"Completed", nil];
    NSArray *icons = [NSArray arrayWithObjects:[UIImage imageNamed:@"Pending-60@2x.png"], [UIImage imageNamed:@"Complete-60@2x.png"], nil];
    segmentedControl = [[URBSegmentedControl alloc]initWithTitles:titles icons:icons];


    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        segmentedControl.frame = CGRectMake(73, 121, 180, 30);

    }
    else if (IS_IPHONE_6)
    {
        segmentedControl.frame = CGRectMake(100, 121, 180, 30);

    }
    else if (IS_IPHONE_6P)
    {
        segmentedControl.frame = CGRectMake(126, 121, 180, 30);

    }

    APIRequest *apiRequest = [[APIRequest alloc]init];
    apiRequest.pendingShipmentDetails ;

    segmentedControl.segmentBackgroundColor = [UIColor colorWithRed:86/255.0f green:199/255.0f blue:188/255.0f alpha:1];
    [segmentedControl addTarget:self action:@selector(handleSelection:) forControlEvents:UIControlEventValueChanged];
    //    NSData* data = [[NSUserDefaults standardUserDefaults] objectForKey:@"data"];
    //    NSMutableArray* arrayList = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    //    NSUInteger arrayLength = [arrayList count];
    NSError *error = nil;

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"PendingShipmentDetails"];


    NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];


    NSArray *result = [self.managedObjectContext executeFetchRequest:request error:&error];
    if (result.count > 0) {
        int i;
        amountArray = [[NSMutableArray alloc] init];
        statusArray = [[NSMutableArray alloc]init];
        shipmentReferenceNumberArray = [[NSMutableArray alloc]init];
        invoiceNumberArray = [[NSMutableArray alloc]init];
        for (i = 0; i < [result count]; i++) {
            //NSLog(@"%@", result);
            pending = (NSManagedObject *)[result objectAtIndex:i];
            //            NSLog(@"pro inv no %@",[pending valueForKey:@"proforma_invoice_no"]);
            //            NSLog(@"shipment no %@",[pending valueForKey:@"shipmentno"]);
            //            NSLog(@"pro inv date %@",[pending valueForKey:@"proforma_invoice_date"]);
            //            NSLog(@"inv no %@",[pending valueForKey:@"invoice_no"]);
            //            NSLog(@"inv date %@",[pending valueForKey:@"invoice_date"]);
            //            NSLog(@"pl sh date %@",[pending valueForKey:@"planned_shipment_date"]);
            //            NSLog(@"pt ct %@",[pending valueForKey:@"point_of_contact"]);
            //            NSLog(@"pro %@",[pending valueForKey:@"products"]);
            //            NSLog(@"qty %@",[pending valueForKey:@"quantity"]);
            //            NSLog(@"rte %@",[pending valueForKey:@"rate"]);
            //            NSLog(@"amt %@",[pending valueForKey:@"amount"]);
            //            NSLog(@"pro imng %@", [pending valueForKey:@"product_image"]);
            //            NSLog(@"statsus %@", [pending valueForKey:@"status"]);

            // amountArray = [[NSMutableArray alloc]initWithObjects:[pending valueForKey:@"amount"], nil];
            [amountArray addObject:[pending valueForKey:@"amount"]];
            [statusArray addObject: [pending valueForKey:@"status"]];
            [shipmentReferenceNumberArray addObject:[pending valueForKey:@"shipmentno"]];
            [invoiceNumberArray addObject:[pending valueForKey:@"invoice_no"]];

        }


        //   shipmentReferenceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"shipmentno"], nil];
        // statusArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"status"], nil];
        //invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"invoice_no"], nil];
        //amountArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"amount"], nil];

    } else {
        NSLog(@"SORRY");
    }

    //    shipmentReferenceNumberArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];
    //    invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];

    // invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@", arrayList[i][@"invoiceNumber"],nil];

    //    statusArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];



    self.completedOrdersTableView.hidden = YES;
    [self.view addSubview:segmentedControl];

    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)viewWillAppear:(BOOL)animated
{
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *v = [UIView new];
    [v setBackgroundColor:[UIColor clearColor]];
    return v;
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [indexPath row] + 200;
}

//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if ([cell respondsToSelector:@selector(tintColor)])
//    {
//        CGFloat cornerRadius = 10;
//        cell.backgroundColor = UIColor.clearColor;
//        CAShapeLayer *layer = [[CAShapeLayer alloc] init];
//        CGMutablePathRef pathRef = CGPathCreateMutable();
//        CGRect bounds = CGRectInset(cell.bounds, 0, 0);
//
//        BOOL addLine = NO;
//        if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1)
//        {
//            CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
//        }
//        else if (indexPath.row == 0)
//        {
//            CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//            CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
//            addLine = YES;
//        }
//        else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
//            CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//            CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
//        }
//        else
//        {
//            CGPathAddRect(pathRef, nil, bounds);
//            addLine = YES;
//        }
//        layer.path = pathRef;
//        CFRelease(pathRef);
//        //set the border color
//        layer.strokeColor = [UIColor clearColor].CGColor;
//        //set the border width
//        layer.lineWidth = 1;
//        layer.fillColor = [UIColor colorWithWhite:1.f alpha:1.0f].CGColor;
//
//
//        if (addLine == YES) {
//            CALayer *lineLayer = [[CALayer alloc] init];
//            CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
//            lineLayer.frame = CGRectMake(CGRectGetMinX(bounds), bounds.size.height-lineHeight, bounds.size.width, lineHeight);
//            lineLayer.backgroundColor = tableView.separatorColor.CGColor;
//            [layer addSublayer:lineLayer];
//        }
//        UIView *testView;
//        testView = [[UIView alloc] initWithFrame:bounds];
//        [testView.layer insertSublayer:layer atIndex:0];
//        testView.backgroundColor = UIColor.clearColor;
//        cell.backgroundView = testView;
//    }
//
//}

- (void)handleSelection:(id)sender
{
    UISegmentedControl *segmentControl = (UISegmentedControl *) sender;
    NSInteger selectedSegment = segmentControl.selectedSegmentIndex;
    if (selectedSegment == 0)
    {
        //toggle the correct view to be visible
        [self.myOrdersTableView setHidden:NO];
        [self.completedOrdersTableView setHidden:YES];

        NSLog(@"hoi");
        NSError *error = nil;

        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

        NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
        [fetchRequest setEntity:entity];


        NSArray *result = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

        if (result.count > 0) {
            NSManagedObject *pending = (NSManagedObject *)[result objectAtIndex:1];


            NSLog(@"statsus %@ %@", [pending valueForKey:@"status"], [pending valueForKey:@"shipmentno"]);


        }

    }
    else
    {
        //toggle the correct view to be visible
        [self.completedOrdersTableView setHidden:NO];
        [self.myOrdersTableView setHidden:YES];
    }
}





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

    UITableViewCell *cell = nil;
    cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:nil];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    UILabel *productAmountTextLabel = [[UILabel alloc]init];

    for (UIView *subView in cell.contentView.subviews) {
        if([subView isKindOfClass:[UILabel class]]){
            [subView removeFromSuperview];
        }
    }

    self.proformaInvoiceLabel = [[UILabel alloc]init];
    self.shipmentStatusLabel = [[UILabel alloc]init];
    self.shipmentStatusDateLabel = [[UILabel alloc]init];
    self.shipmentReferenceNumberLabel = [[UILabel alloc]init];
    self.shipmentReferenceNumberTextLabel = [[UILabel alloc]init];
    self.invoiceDateLabel = [[UILabel alloc]init];
    self.invoiceLabel = [[UILabel alloc]init];
    self.estimatedDateLabel = [[UILabel alloc]init];
    self.estimatedDateTextLabel = [[UILabel alloc]init];
    self.estimatedTimeArrivalLabel = [[UILabel alloc]init];
    self.estimatedTimeArrivalTextLabel = [[UILabel alloc]init];
    self.productImage = [[UIImageView alloc]init];
    self.productNameLabel = [[UILabel alloc]init];
    self.productQuantityLabel = [[UILabel alloc]init];
    self.productQuantityTextLabel = [[UILabel alloc]init];
    self.productRateLabel = [[UILabel alloc]init];
    self.productRateTextLabel = [[UILabel alloc]init];
    self.productAmountLabel = [[UILabel alloc]init];
    productAmountTextLabel = [[UILabel alloc]init];
    self.vaighaiWorldWideLabel = [[UILabel alloc]init];

    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(150, 170, 200, 30);

    }
    else if (IS_IPHONE_6)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(205, 170, 200, 30);
    }
    else if (IS_IPHONE_6P)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(234, 170, 200, 30);

    }



    self.shipmentReferenceNumberLabel.text = @"Shipment Ref. #:";
    self.shipmentReferenceNumberLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.shipmentReferenceNumberTextLabel.text = @"shipment_ref_no";
    self.shipmentReferenceNumberTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productNameLabel.text = @"products";
    self.productNameLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:10];

    self.productAmountLabel.text = @"Amount:";
    self.productAmountLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    //    self.productAmountTextLabel.text = @"amount";
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    int i;
    for (i = 0 ; i<[shipmentReferenceNumberArray count]; i++){
        NSLog(@"as %@",amountArray[i]);
    }
    NSLog(@"huhuhu %@",[NSString stringWithFormat:@"%@",amountArray[indexPath.row]]);

    //    self.productAmountTextLabel.text =  [NSString stringWithFormat:@"%@",amountArray[indexPath.row]];
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    productAmountTextLabel.text = amountArray[indexPath.row];
    productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productQuantityLabel.text = @"Quantity:";
    self.productQuantityLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productQuantityTextLabel.text = @"quantity";
    self.productQuantityTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.invoiceLabel.text = @"invoiceNumber";
    self.invoiceLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.invoiceDateLabel.text = @"invoiceDate";
    self.invoiceDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.proformaInvoiceLabel.text = @"shipment_ref_no";
    self.proformaInvoiceLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];



    self.shipmentStatusLabel.text = @"Cargo Shipped";
    self.shipmentStatusLabel.font = [UIFont fontWithName:@"HelveticaNeue-BoldItalic" size:10];

    self.shipmentStatusDateLabel.text = @"shipped date";
    self.shipmentStatusDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedDateLabel.text = @"ETD:";
    self.estimatedDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedDateTextLabel.text = @"etd";
    self.estimatedDateTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedTimeArrivalLabel.text = @"/ ETA:";
    self.estimatedTimeArrivalLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedTimeArrivalTextLabel.text = @"eta";
    self.estimatedTimeArrivalTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productImage.image = [UIImage imageNamed:@"BioMass Pellets.jpg"];


    self.productRateLabel.text = @"Rate:";
    self.productRateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productRateTextLabel.text = @"USD 100";
    self.productRateTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.vaighaiWorldWideLabel.text = @"Shipped by Vaighai World Wide";
    self.vaighaiWorldWideLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:10];

    tableView.tableFooterView = [UIView new];

    cell.layer.borderWidth = 1.0;
    cell.layer.cornerRadius = 10;
    cell.layer.borderColor = [UIColor blackColor].CGColor;


    [cell.contentView addSubview:self.proformaInvoiceLabel];
    [cell.contentView addSubview:self.shipmentReferenceNumberLabel];
    [cell.contentView addSubview:self.shipmentReferenceNumberTextLabel];
    [cell.contentView addSubview:self.shipmentStatusDateLabel];
    [cell.contentView addSubview:self.shipmentStatusLabel];
    [cell.contentView addSubview:self.invoiceDateLabel];
    [cell.contentView addSubview:self.invoiceLabel];
    [cell.contentView addSubview:self.estimatedDateLabel];
    [cell.contentView addSubview:self.estimatedDateTextLabel];
    [cell.contentView addSubview:self.estimatedTimeArrivalLabel];
    [cell.contentView addSubview:self.estimatedTimeArrivalTextLabel];
    [cell.contentView addSubview:self.productImage];
    [cell.contentView addSubview:self.productNameLabel];
    [cell.contentView addSubview:self.productQuantityLabel];
    [cell.contentView addSubview:self.productQuantityTextLabel];
    [cell.contentView addSubview:self.productRateLabel];
    [cell.contentView addSubview:self.productRateTextLabel];
    [cell.contentView addSubview:self.productAmountLabel];
    [cell.contentView addSubview:productAmountTextLabel];
    [cell.contentView addSubview:self.vaighaiWorldWideLabel];
    //    cell.layer.shadowColor = [[UIColor blackColor] CGColor];
    //    cell.layer.shadowOffset = CGSizeMake(0.0f,0.0f);
    //    cell.layer.shadowOpacity = 0.7f;
    //    cell.layer.shadowRadius = 4.0f;
    //[cell.layer setMasksToBounds:YES];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
    // NSLog(@"you have selected %d",indexPath.row);
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [tableView setAllowsSelection:YES];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];


    tabBar = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];

    [self.navigationController pushViewController:tabBar animated:YES];

}
- (void)viewDidLoad
{
    //    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    //
    //    [self.navigationController.navigationBar.topItem setTitle:@"Shipment Tracking System"];

    NSArray *titles = [NSArray arrayWithObjects:@"Pending",@"Completed", nil];
    NSArray *icons = [NSArray arrayWithObjects:[UIImage imageNamed:@"Pending-60@2x.png"], [UIImage imageNamed:@"Complete-60@2x.png"], nil];
    segmentedControl = [[URBSegmentedControl alloc]initWithTitles:titles icons:icons];


    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        segmentedControl.frame = CGRectMake(73, 121, 180, 30);

    }
    else if (IS_IPHONE_6)
    {
        segmentedControl.frame = CGRectMake(100, 121, 180, 30);

    }
    else if (IS_IPHONE_6P)
    {
        segmentedControl.frame = CGRectMake(126, 121, 180, 30);

    }

    APIRequest *apiRequest = [[APIRequest alloc]init];
    apiRequest.pendingShipmentDetails ;

    segmentedControl.segmentBackgroundColor = [UIColor colorWithRed:86/255.0f green:199/255.0f blue:188/255.0f alpha:1];
    [segmentedControl addTarget:self action:@selector(handleSelection:) forControlEvents:UIControlEventValueChanged];
    //    NSData* data = [[NSUserDefaults standardUserDefaults] objectForKey:@"data"];
    //    NSMutableArray* arrayList = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    //    NSUInteger arrayLength = [arrayList count];
    NSError *error = nil;

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"PendingShipmentDetails"];


    NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];


    NSArray *result = [self.managedObjectContext executeFetchRequest:request error:&error];
    if (result.count > 0) {
        int i;
        amountArray = [[NSMutableArray alloc] init];
        statusArray = [[NSMutableArray alloc]init];
        shipmentReferenceNumberArray = [[NSMutableArray alloc]init];
        invoiceNumberArray = [[NSMutableArray alloc]init];
        for (i = 0; i < [result count]; i++) {
            //NSLog(@"%@", result);
            pending = (NSManagedObject *)[result objectAtIndex:i];
            //            NSLog(@"pro inv no %@",[pending valueForKey:@"proforma_invoice_no"]);
            //            NSLog(@"shipment no %@",[pending valueForKey:@"shipmentno"]);
            //            NSLog(@"pro inv date %@",[pending valueForKey:@"proforma_invoice_date"]);
            //            NSLog(@"inv no %@",[pending valueForKey:@"invoice_no"]);
            //            NSLog(@"inv date %@",[pending valueForKey:@"invoice_date"]);
            //            NSLog(@"pl sh date %@",[pending valueForKey:@"planned_shipment_date"]);
            //            NSLog(@"pt ct %@",[pending valueForKey:@"point_of_contact"]);
            //            NSLog(@"pro %@",[pending valueForKey:@"products"]);
            //            NSLog(@"qty %@",[pending valueForKey:@"quantity"]);
            //            NSLog(@"rte %@",[pending valueForKey:@"rate"]);
            //            NSLog(@"amt %@",[pending valueForKey:@"amount"]);
            //            NSLog(@"pro imng %@", [pending valueForKey:@"product_image"]);
            //            NSLog(@"statsus %@", [pending valueForKey:@"status"]);

            // amountArray = [[NSMutableArray alloc]initWithObjects:[pending valueForKey:@"amount"], nil];
            [amountArray addObject:[pending valueForKey:@"amount"]];
            [statusArray addObject: [pending valueForKey:@"status"]];
            [shipmentReferenceNumberArray addObject:[pending valueForKey:@"shipmentno"]];
            [invoiceNumberArray addObject:[pending valueForKey:@"invoice_no"]];

        }


        //   shipmentReferenceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"shipmentno"], nil];
        // statusArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"status"], nil];
        //invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"invoice_no"], nil];
        //amountArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"amount"], nil];

    } else {
        NSLog(@"SORRY");
    }

    //    shipmentReferenceNumberArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];
    //    invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];

    // invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@", arrayList[i][@"invoiceNumber"],nil];

    //    statusArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];



    self.completedOrdersTableView.hidden = YES;
    [self.view addSubview:segmentedControl];

    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)viewWillAppear:(BOOL)animated
{
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *v = [UIView new];
    [v setBackgroundColor:[UIColor clearColor]];
    return v;
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [indexPath row] + 200;
}

//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if ([cell respondsToSelector:@selector(tintColor)])
//    {
//        CGFloat cornerRadius = 10;
//        cell.backgroundColor = UIColor.clearColor;
//        CAShapeLayer *layer = [[CAShapeLayer alloc] init];
//        CGMutablePathRef pathRef = CGPathCreateMutable();
//        CGRect bounds = CGRectInset(cell.bounds, 0, 0);
//
//        BOOL addLine = NO;
//        if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1)
//        {
//            CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
//        }
//        else if (indexPath.row == 0)
//        {
//            CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//            CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
//            addLine = YES;
//        }
//        else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
//            CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//            CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
//        }
//        else
//        {
//            CGPathAddRect(pathRef, nil, bounds);
//            addLine = YES;
//        }
//        layer.path = pathRef;
//        CFRelease(pathRef);
//        //set the border color
//        layer.strokeColor = [UIColor clearColor].CGColor;
//        //set the border width
//        layer.lineWidth = 1;
//        layer.fillColor = [UIColor colorWithWhite:1.f alpha:1.0f].CGColor;
//
//
//        if (addLine == YES) {
//            CALayer *lineLayer = [[CALayer alloc] init];
//            CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
//            lineLayer.frame = CGRectMake(CGRectGetMinX(bounds), bounds.size.height-lineHeight, bounds.size.width, lineHeight);
//            lineLayer.backgroundColor = tableView.separatorColor.CGColor;
//            [layer addSublayer:lineLayer];
//        }
//        UIView *testView;
//        testView = [[UIView alloc] initWithFrame:bounds];
//        [testView.layer insertSublayer:layer atIndex:0];
//        testView.backgroundColor = UIColor.clearColor;
//        cell.backgroundView = testView;
//    }
//
//}

- (void)handleSelection:(id)sender
{
    UISegmentedControl *segmentControl = (UISegmentedControl *) sender;
    NSInteger selectedSegment = segmentControl.selectedSegmentIndex;
    if (selectedSegment == 0)
    {
        //toggle the correct view to be visible
        [self.myOrdersTableView setHidden:NO];
        [self.completedOrdersTableView setHidden:YES];

        NSLog(@"hoi");
        NSError *error = nil;

        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

        NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
        [fetchRequest setEntity:entity];


        NSArray *result = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

        if (result.count > 0) {
            NSManagedObject *pending = (NSManagedObject *)[result objectAtIndex:1];


            NSLog(@"statsus %@ %@", [pending valueForKey:@"status"], [pending valueForKey:@"shipmentno"]);


        }

    }
    else
    {
        //toggle the correct view to be visible
        [self.completedOrdersTableView setHidden:NO];
        [self.myOrdersTableView setHidden:YES];
    }
}





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

    UITableViewCell *cell = nil;
    cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:nil];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    UILabel *productAmountTextLabel = [[UILabel alloc]init];

    for (UIView *subView in cell.contentView.subviews) {
        if([subView isKindOfClass:[UILabel class]]){
            [subView removeFromSuperview];
        }
    }

    self.proformaInvoiceLabel = [[UILabel alloc]init];
    self.shipmentStatusLabel = [[UILabel alloc]init];
    self.shipmentStatusDateLabel = [[UILabel alloc]init];
    self.shipmentReferenceNumberLabel = [[UILabel alloc]init];
    self.shipmentReferenceNumberTextLabel = [[UILabel alloc]init];
    self.invoiceDateLabel = [[UILabel alloc]init];
    self.invoiceLabel = [[UILabel alloc]init];
    self.estimatedDateLabel = [[UILabel alloc]init];
    self.estimatedDateTextLabel = [[UILabel alloc]init];
    self.estimatedTimeArrivalLabel = [[UILabel alloc]init];
    self.estimatedTimeArrivalTextLabel = [[UILabel alloc]init];
    self.productImage = [[UIImageView alloc]init];
    self.productNameLabel = [[UILabel alloc]init];
    self.productQuantityLabel = [[UILabel alloc]init];
    self.productQuantityTextLabel = [[UILabel alloc]init];
    self.productRateLabel = [[UILabel alloc]init];
    self.productRateTextLabel = [[UILabel alloc]init];
    self.productAmountLabel = [[UILabel alloc]init];
    productAmountTextLabel = [[UILabel alloc]init];
    self.vaighaiWorldWideLabel = [[UILabel alloc]init];

    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(150, 170, 200, 30);

    }
    else if (IS_IPHONE_6)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(205, 170, 200, 30);
    }
    else if (IS_IPHONE_6P)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(234, 170, 200, 30);

    }



    self.shipmentReferenceNumberLabel.text = @"Shipment Ref. #:";
    self.shipmentReferenceNumberLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.shipmentReferenceNumberTextLabel.text = @"shipment_ref_no";
    self.shipmentReferenceNumberTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productNameLabel.text = @"products";
    self.productNameLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:10];

    self.productAmountLabel.text = @"Amount:";
    self.productAmountLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    //    self.productAmountTextLabel.text = @"amount";
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    int i;
    for (i = 0 ; i<[shipmentReferenceNumberArray count]; i++){
        NSLog(@"as %@",amountArray[i]);
    }
    NSLog(@"huhuhu %@",[NSString stringWithFormat:@"%@",amountArray[indexPath.row]]);

    //    self.productAmountTextLabel.text =  [NSString stringWithFormat:@"%@",amountArray[indexPath.row]];
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    productAmountTextLabel.text = amountArray[indexPath.row];
    productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productQuantityLabel.text = @"Quantity:";
    self.productQuantityLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productQuantityTextLabel.text = @"quantity";
    self.productQuantityTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.invoiceLabel.text = @"invoiceNumber";
    self.invoiceLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.invoiceDateLabel.text = @"invoiceDate";
    self.invoiceDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.proformaInvoiceLabel.text = @"shipment_ref_no";
    self.proformaInvoiceLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];



    self.shipmentStatusLabel.text = @"Cargo Shipped";
    self.shipmentStatusLabel.font = [UIFont fontWithName:@"HelveticaNeue-BoldItalic" size:10];

    self.shipmentStatusDateLabel.text = @"shipped date";
    self.shipmentStatusDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedDateLabel.text = @"ETD:";
    self.estimatedDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedDateTextLabel.text = @"etd";
    self.estimatedDateTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedTimeArrivalLabel.text = @"/ ETA:";
    self.estimatedTimeArrivalLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedTimeArrivalTextLabel.text = @"eta";
    self.estimatedTimeArrivalTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productImage.image = [UIImage imageNamed:@"BioMass Pellets.jpg"];


    self.productRateLabel.text = @"Rate:";
    self.productRateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productRateTextLabel.text = @"USD 100";
    self.productRateTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.vaighaiWorldWideLabel.text = @"Shipped by Vaighai World Wide";
    self.vaighaiWorldWideLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:10];

    tableView.tableFooterView = [UIView new];

    cell.layer.borderWidth = 1.0;
    cell.layer.cornerRadius = 10;
    cell.layer.borderColor = [UIColor blackColor].CGColor;


    [cell.contentView addSubview:self.proformaInvoiceLabel];
    [cell.contentView addSubview:self.shipmentReferenceNumberLabel];
    [cell.contentView addSubview:self.shipmentReferenceNumberTextLabel];
    [cell.contentView addSubview:self.shipmentStatusDateLabel];
    [cell.contentView addSubview:self.shipmentStatusLabel];
    [cell.contentView addSubview:self.invoiceDateLabel];
    [cell.contentView addSubview:self.invoiceLabel];
    [cell.contentView addSubview:self.estimatedDateLabel];
    [cell.contentView addSubview:self.estimatedDateTextLabel];
    [cell.contentView addSubview:self.estimatedTimeArrivalLabel];
    [cell.contentView addSubview:self.estimatedTimeArrivalTextLabel];
    [cell.contentView addSubview:self.productImage];
    [cell.contentView addSubview:self.productNameLabel];
    [cell.contentView addSubview:self.productQuantityLabel];
    [cell.contentView addSubview:self.productQuantityTextLabel];
    [cell.contentView addSubview:self.productRateLabel];
    [cell.contentView addSubview:self.productRateTextLabel];
    [cell.contentView addSubview:self.productAmountLabel];
    [cell.contentView addSubview:productAmountTextLabel];
    [cell.contentView addSubview:self.vaighaiWorldWideLabel];
    //    cell.layer.shadowColor = [[UIColor blackColor] CGColor];
    //    cell.layer.shadowOffset = CGSizeMake(0.0f,0.0f);
    //    cell.layer.shadowOpacity = 0.7f;
    //    cell.layer.shadowRadius = 4.0f;
    //[cell.layer setMasksToBounds:YES];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
    // NSLog(@"you have selected %d",indexPath.row);
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [tableView setAllowsSelection:YES];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];


    tabBar = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];

    [self.navigationController pushViewController:tabBar animated:YES];

}
-(void)viewDidLoad
{
//self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor whiteColor]};
//
//[self.navigationController.navigationBar.topItem setTitle:@“装运跟踪系统”];
NSArray*标题=[NSArray arrayWithObjects:@“待定”,“已完成”,无];
NSArray*图标=[NSArray arrayWithObjects:[UIImage ImageName:@”挂起-60@2x.png“],[UIImage ImageName:@”完成-60@2x.png“],无];
segmentedControl=[[URBSegmentedControl alloc]initWithTitles:标题图标:图标];
如果(是IPHONE 4还是更少?是IPHONE 5)
{
segmentedControl.frame=CGRectMake(73,121,180,30);
}
否则如果(是IPHONE 6)
{
segmentedControl.frame=CGRectMake(100,121,180,30);
}
否则如果(是IPHONE_6P)
{
segmentedControl.frame=CGRectMake(126、121、180、30);
}
APIRequest*APIRequest=[[APIRequest alloc]init];
apiRequest.pendingShipmentDetails;
segmentedControl.segmentBackgroundColor=[UIColor COLOR WITH RED:86/255.0f绿色:199/255.0f蓝色:188/255.0f alpha:1];
[分段控件添加目标:自我操作:@选择器(handleSelection:)for ControlEvents:UIControlEventValueChanged];
//NSData*数据=[[NSUserDefaults standardUserDefaults]objectForKey:@“数据”];
//NSMutableArray*arrayList=[NSKeyedUnarchiveObjectWithData:data];
//NSUTEGER arrayLength=[arrayList count];
n错误*错误=nil;
NSFetchRequest*fetchRequest=[[NSFetchRequest alloc]init];
NSFetchRequest*request=[[NSFetchRequest alloc]initWithEntityName:@“PendingShipmentDetails”];
NSEntityDescription*entity=[NSEntityDescription entityForName:@“PendingShipmentDetails”在managedObjectContext:self.managedObjectContext]中;
[FetchRequestSetEntity:entity];
NSArray*结果=[self.managedObjectContext executeFetchRequest:请求错误:&错误];
如果(result.count>0){
int i;
amountArray=[[NSMutableArray alloc]init];
statusArray=[[NSMutableArray alloc]init];
shipmentReferenceNumberArray=[[NSMutableArray alloc]init];
invoiceNumberArray=[[NSMutableArray alloc]init];
对于(i=0;i<[结果计数];i++){
//NSLog(@“%@”,结果);
未决=(NSManagedObject*)[result objectAtIndex:i];
//NSLog(@“pro inv no%@,[待定价值:形式发票编号]);
//NSLog(@“装运编号%@,[待定值Forkey:@“装运编号]);
//NSLog(@“预投资日期%@,[待定价值:形式发票日期]);
//NSLog(@“发票号%@,[待定价值:发票号]);
//NSLog(@“发票日期%@,[待定值Forkey:@“发票日期]);
//NSLog(@“pl sh日期%@,[待定值:计划装运日期]);
//NSLog(@“pt ct%@,[待定值:联系点]);
//NSLog(@“pro%@,[待定的valueForKey:@“产品]);
//NSLog(@“数量%@,[pending valueForKey:@“数量”);
//NSLog(@“rte%@,[pending valueForKey:@“rate”]);
//NSLog(@“金额%@,[pending valueForKey:@“金额”);
//NSLog(@“pro imng%@,[pending valueForKey:@“product_image]”);
//NSLog(@“statsus%@,[pending valueForKey:@“status]”);
//amountArray=[[NSMutableArray alloc]initWithObjects:[pending valueForKey:@“amount”],nil];
[amountArray addObject:[pending valueForKey:@“amount”];
[statusArray addObject:[pending valueForKey:@“status”];
[shipmentReferenceNumberArray addObject:[pending valueForKey:@“shipmentno”];
[invoiceNumberArray addObject:[待定值forkey:@“发票号”];
}
//shipmentReferenceNumberArray=[[NSMutableArray alloc]initWithObjects:@“%@,[pending valueForKey:@“shipmentno”],nil];
//statusArray=[[NSMutableArray alloc]initWithObjects:@“%@,[pending valueForKey:@“status”],nil];
//invoiceNumberArray=[[NSMutableArray alloc]initWithObjects:@“%@,[pending valueForKey:@“发票编号”],无];
//amountArray=[[NSMutableArray alloc]initWithObjects:@“%@,[pending valueForKey:@“amount”],nil];
}否则{
NSLog(“对不起”);
}
//shipmentReferenceNumberArray=[[NSMutableArray alloc]initWithObjects:@“船上货物”、“生产中”、“正在填充”、“生产中”、“船上货物”、“正在进行质量检查”、“收到待装运货物”,无];
//invoiceNumberArray=[[NSMutableArray alloc]initWithObjects:@“船上货物”、“生产中”、“正在填充”、“生产中”、“船上货物”、“正在进行质量检查”、“收到待装运货物”,无];
//invoiceNumberArray=[[NSMutableArray alloc]initWithObjects:@“%@”,arrayList[i][@“invoiceNumber”],nil];
//statusArray=[[NSMutableArray alloc]initWithObjects:@“船上货物”、“生产中”、“正在填充”、“生产中”、“船上货物”、“正在进行质量检查”、“收到待装运货物”,无];
self.completedOrdersTableView.hidden=是;
[self.view addSubview:segmentedControl];
[超级视图下载];
//加载视图后执行任何其他设置。
}
-(无效)视图将显示:(BOOL)动画
{
}
-(UIView*)表格视图:(UITableView*)表格视图用于标题部分:(NSInteger)部分
{
UIView*v=[UIView new];
[v setBackgroundColor:[UIColor clearColor]];
返回
  self.productAmountTextLabel.text = amountArray[i];
    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"PendingShipmentDetails"];


        NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
        [fetchRequest setEntity:entity];


        NSArray *result = [self.managedObjectContext executeFetchRequest:request error:&error];


        if (result.count > 0) {
    statusArray = [[NSMutableArray alloc]init];
    amountArray = [[NSMutableArray alloc]init];
            int i;
            for (i = 0; i < [result count]; i++) {
                NSManagedObject *pending = (NSManagedObject *)[result objectAtIndex:i];

                [statusArray addObject: [pending valueForKey:@"invoice_no"]];
                [amountArray addObject: [pending valueForKey:@"amount"]];
            }
    }

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

    UITableViewCell *cell = nil;
    cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:nil];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    for (UIView *subView in cell.contentView.subviews) {
        if([subView isKindOfClass:[UILabel class]]){
            [subView removeFromSuperview];
        }
    }

     UILabel *productAmountLabel = [[UILabel alloc]init];
    UILabel *productAmountTextLabel = [[UILabel alloc]init];

    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);

    }
    else if (IS_IPHONE_6)
    {

        productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
    }
    else if (IS_IPHONE_6P)
    {

        productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);

    }




    productAmountLabel.text = @"Amount:";
    productAmountLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    //    self.productAmountTextLabel.text =  [NSString stringWithFormat:@"%@",amountArray[indexPath.row]];
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    productAmountTextLabel.text = amountArray[indexPath.row];
    productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];


    tableView.tableFooterView = [UIView new];

    cell.layer.borderWidth = 1.0;
    cell.layer.cornerRadius = 10;
    cell.layer.borderColor = [UIColor blackColor].CGColor;



    [cell.contentView addSubview:productAmountLabel];
    [cell.contentView addSubview:productAmountTextLabel];

    //    cell.layer.shadowColor = [[UIColor blackColor] CGColor];
    //    cell.layer.shadowOffset = CGSizeMake(0.0f,0.0f);
    //    cell.layer.shadowOpacity = 0.7f;
    //    cell.layer.shadowRadius = 4.0f;
    //[cell.layer setMasksToBounds:YES];

    return cell;
}
- (void)viewDidLoad
{
    //    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    //
    //    [self.navigationController.navigationBar.topItem setTitle:@"Shipment Tracking System"];

    NSArray *titles = [NSArray arrayWithObjects:@"Pending",@"Completed", nil];
    NSArray *icons = [NSArray arrayWithObjects:[UIImage imageNamed:@"Pending-60@2x.png"], [UIImage imageNamed:@"Complete-60@2x.png"], nil];
    segmentedControl = [[URBSegmentedControl alloc]initWithTitles:titles icons:icons];


    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        segmentedControl.frame = CGRectMake(73, 121, 180, 30);

    }
    else if (IS_IPHONE_6)
    {
        segmentedControl.frame = CGRectMake(100, 121, 180, 30);

    }
    else if (IS_IPHONE_6P)
    {
        segmentedControl.frame = CGRectMake(126, 121, 180, 30);

    }

    APIRequest *apiRequest = [[APIRequest alloc]init];
    apiRequest.pendingShipmentDetails ;

    segmentedControl.segmentBackgroundColor = [UIColor colorWithRed:86/255.0f green:199/255.0f blue:188/255.0f alpha:1];
    [segmentedControl addTarget:self action:@selector(handleSelection:) forControlEvents:UIControlEventValueChanged];
    //    NSData* data = [[NSUserDefaults standardUserDefaults] objectForKey:@"data"];
    //    NSMutableArray* arrayList = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    //    NSUInteger arrayLength = [arrayList count];
    NSError *error = nil;

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"PendingShipmentDetails"];


    NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];


    NSArray *result = [self.managedObjectContext executeFetchRequest:request error:&error];
    if (result.count > 0) {
        int i;
        amountArray = [[NSMutableArray alloc] init];
        statusArray = [[NSMutableArray alloc]init];
        shipmentReferenceNumberArray = [[NSMutableArray alloc]init];
        invoiceNumberArray = [[NSMutableArray alloc]init];
        for (i = 0; i < [result count]; i++) {
            //NSLog(@"%@", result);
            pending = (NSManagedObject *)[result objectAtIndex:i];
            //            NSLog(@"pro inv no %@",[pending valueForKey:@"proforma_invoice_no"]);
            //            NSLog(@"shipment no %@",[pending valueForKey:@"shipmentno"]);
            //            NSLog(@"pro inv date %@",[pending valueForKey:@"proforma_invoice_date"]);
            //            NSLog(@"inv no %@",[pending valueForKey:@"invoice_no"]);
            //            NSLog(@"inv date %@",[pending valueForKey:@"invoice_date"]);
            //            NSLog(@"pl sh date %@",[pending valueForKey:@"planned_shipment_date"]);
            //            NSLog(@"pt ct %@",[pending valueForKey:@"point_of_contact"]);
            //            NSLog(@"pro %@",[pending valueForKey:@"products"]);
            //            NSLog(@"qty %@",[pending valueForKey:@"quantity"]);
            //            NSLog(@"rte %@",[pending valueForKey:@"rate"]);
            //            NSLog(@"amt %@",[pending valueForKey:@"amount"]);
            //            NSLog(@"pro imng %@", [pending valueForKey:@"product_image"]);
            //            NSLog(@"statsus %@", [pending valueForKey:@"status"]);

            // amountArray = [[NSMutableArray alloc]initWithObjects:[pending valueForKey:@"amount"], nil];
            [amountArray addObject:[pending valueForKey:@"amount"]];
            [statusArray addObject: [pending valueForKey:@"status"]];
            [shipmentReferenceNumberArray addObject:[pending valueForKey:@"shipmentno"]];
            [invoiceNumberArray addObject:[pending valueForKey:@"invoice_no"]];

        }


        //   shipmentReferenceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"shipmentno"], nil];
        // statusArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"status"], nil];
        //invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"invoice_no"], nil];
        //amountArray = [[NSMutableArray alloc]initWithObjects:@"%@",[pending valueForKey:@"amount"], nil];

    } else {
        NSLog(@"SORRY");
    }

    //    shipmentReferenceNumberArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];
    //    invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];

    // invoiceNumberArray = [[NSMutableArray alloc]initWithObjects:@"%@", arrayList[i][@"invoiceNumber"],nil];

    //    statusArray = [[NSMutableArray alloc]initWithObjects:@"Cargo Onboard",@"In Production",@"Stuffing in Progress",@"In Production",@"Cargo Onboard",@"Quality Check in Progress",@"Goods received for Shipment", nil];



    self.completedOrdersTableView.hidden = YES;
    [self.view addSubview:segmentedControl];

    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)viewWillAppear:(BOOL)animated
{
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *v = [UIView new];
    [v setBackgroundColor:[UIColor clearColor]];
    return v;
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [indexPath row] + 200;
}

//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if ([cell respondsToSelector:@selector(tintColor)])
//    {
//        CGFloat cornerRadius = 10;
//        cell.backgroundColor = UIColor.clearColor;
//        CAShapeLayer *layer = [[CAShapeLayer alloc] init];
//        CGMutablePathRef pathRef = CGPathCreateMutable();
//        CGRect bounds = CGRectInset(cell.bounds, 0, 0);
//
//        BOOL addLine = NO;
//        if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1)
//        {
//            CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
//        }
//        else if (indexPath.row == 0)
//        {
//            CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//            CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
//            addLine = YES;
//        }
//        else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
//            CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
//            CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
//            CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
//        }
//        else
//        {
//            CGPathAddRect(pathRef, nil, bounds);
//            addLine = YES;
//        }
//        layer.path = pathRef;
//        CFRelease(pathRef);
//        //set the border color
//        layer.strokeColor = [UIColor clearColor].CGColor;
//        //set the border width
//        layer.lineWidth = 1;
//        layer.fillColor = [UIColor colorWithWhite:1.f alpha:1.0f].CGColor;
//
//
//        if (addLine == YES) {
//            CALayer *lineLayer = [[CALayer alloc] init];
//            CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
//            lineLayer.frame = CGRectMake(CGRectGetMinX(bounds), bounds.size.height-lineHeight, bounds.size.width, lineHeight);
//            lineLayer.backgroundColor = tableView.separatorColor.CGColor;
//            [layer addSublayer:lineLayer];
//        }
//        UIView *testView;
//        testView = [[UIView alloc] initWithFrame:bounds];
//        [testView.layer insertSublayer:layer atIndex:0];
//        testView.backgroundColor = UIColor.clearColor;
//        cell.backgroundView = testView;
//    }
//
//}

- (void)handleSelection:(id)sender
{
    UISegmentedControl *segmentControl = (UISegmentedControl *) sender;
    NSInteger selectedSegment = segmentControl.selectedSegmentIndex;
    if (selectedSegment == 0)
    {
        //toggle the correct view to be visible
        [self.myOrdersTableView setHidden:NO];
        [self.completedOrdersTableView setHidden:YES];

        NSLog(@"hoi");
        NSError *error = nil;

        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

        NSEntityDescription *entity = [NSEntityDescription entityForName:@"PendingShipmentDetails" inManagedObjectContext:self.managedObjectContext];
        [fetchRequest setEntity:entity];


        NSArray *result = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

        if (result.count > 0) {
            NSManagedObject *pending = (NSManagedObject *)[result objectAtIndex:1];


            NSLog(@"statsus %@ %@", [pending valueForKey:@"status"], [pending valueForKey:@"shipmentno"]);


        }

    }
    else
    {
        //toggle the correct view to be visible
        [self.completedOrdersTableView setHidden:NO];
        [self.myOrdersTableView setHidden:YES];
    }
}





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

    UITableViewCell *cell = nil;
    cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:nil];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    UILabel *productAmountTextLabel = [[UILabel alloc]init];

    for (UIView *subView in cell.contentView.subviews) {
        if([subView isKindOfClass:[UILabel class]]){
            [subView removeFromSuperview];
        }
    }

    self.proformaInvoiceLabel = [[UILabel alloc]init];
    self.shipmentStatusLabel = [[UILabel alloc]init];
    self.shipmentStatusDateLabel = [[UILabel alloc]init];
    self.shipmentReferenceNumberLabel = [[UILabel alloc]init];
    self.shipmentReferenceNumberTextLabel = [[UILabel alloc]init];
    self.invoiceDateLabel = [[UILabel alloc]init];
    self.invoiceLabel = [[UILabel alloc]init];
    self.estimatedDateLabel = [[UILabel alloc]init];
    self.estimatedDateTextLabel = [[UILabel alloc]init];
    self.estimatedTimeArrivalLabel = [[UILabel alloc]init];
    self.estimatedTimeArrivalTextLabel = [[UILabel alloc]init];
    self.productImage = [[UIImageView alloc]init];
    self.productNameLabel = [[UILabel alloc]init];
    self.productQuantityLabel = [[UILabel alloc]init];
    self.productQuantityTextLabel = [[UILabel alloc]init];
    self.productRateLabel = [[UILabel alloc]init];
    self.productRateTextLabel = [[UILabel alloc]init];
    self.productAmountLabel = [[UILabel alloc]init];
    productAmountTextLabel = [[UILabel alloc]init];
    self.vaighaiWorldWideLabel = [[UILabel alloc]init];

    if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(150, 170, 200, 30);

    }
    else if (IS_IPHONE_6)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(205, 170, 200, 30);
    }
    else if (IS_IPHONE_6P)
    {
        self.proformaInvoiceLabel.frame = CGRectMake(10, 3, 100, 30);
        self.shipmentStatusLabel.frame = CGRectMake(10, 20, 100, 30);
        self.shipmentStatusDateLabel.frame = CGRectMake(85, 20, 100, 30);
        self.invoiceLabel.frame = CGRectMake(10, 40, 100, 30);
        self.invoiceDateLabel.frame = CGRectMake(70, 40, 100, 30);
        self.shipmentReferenceNumberLabel.frame = CGRectMake(10, 60, 100, 30);
        self.shipmentReferenceNumberTextLabel.frame = CGRectMake(88, 60, 100, 30);
        self.estimatedDateLabel.frame = CGRectMake(10, 80, 100, 30);
        self.estimatedDateTextLabel.frame = CGRectMake(35, 80, 100, 30);
        self.estimatedTimeArrivalLabel.frame = CGRectMake(92, 80, 100, 30);
        self.estimatedTimeArrivalTextLabel.frame = CGRectMake(122, 80, 100, 30);
        self.productImage.frame = CGRectMake(10, 110, 60, 60);
        self.productNameLabel.frame = CGRectMake(75, 100, 100, 30);
        self.productQuantityLabel.frame = CGRectMake(75, 115, 100, 30);
        self.productQuantityTextLabel.frame = CGRectMake(120, 115, 100, 30);
        self.productRateLabel.frame = CGRectMake(75, 130, 100, 30);
        self.productRateTextLabel.frame = CGRectMake(102, 130, 100, 30);
        self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
        productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
        self.vaighaiWorldWideLabel.frame = CGRectMake(234, 170, 200, 30);

    }



    self.shipmentReferenceNumberLabel.text = @"Shipment Ref. #:";
    self.shipmentReferenceNumberLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.shipmentReferenceNumberTextLabel.text = @"shipment_ref_no";
    self.shipmentReferenceNumberTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productNameLabel.text = @"products";
    self.productNameLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:10];

    self.productAmountLabel.text = @"Amount:";
    self.productAmountLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    //    self.productAmountTextLabel.text = @"amount";
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    int i;
    for (i = 0 ; i<[shipmentReferenceNumberArray count]; i++){
        NSLog(@"as %@",amountArray[i]);
    }
    NSLog(@"huhuhu %@",[NSString stringWithFormat:@"%@",amountArray[indexPath.row]]);

    //    self.productAmountTextLabel.text =  [NSString stringWithFormat:@"%@",amountArray[indexPath.row]];
    //    self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    productAmountTextLabel.text = amountArray[indexPath.row];
    productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productQuantityLabel.text = @"Quantity:";
    self.productQuantityLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productQuantityTextLabel.text = @"quantity";
    self.productQuantityTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.invoiceLabel.text = @"invoiceNumber";
    self.invoiceLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.invoiceDateLabel.text = @"invoiceDate";
    self.invoiceDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.proformaInvoiceLabel.text = @"shipment_ref_no";
    self.proformaInvoiceLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];



    self.shipmentStatusLabel.text = @"Cargo Shipped";
    self.shipmentStatusLabel.font = [UIFont fontWithName:@"HelveticaNeue-BoldItalic" size:10];

    self.shipmentStatusDateLabel.text = @"shipped date";
    self.shipmentStatusDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedDateLabel.text = @"ETD:";
    self.estimatedDateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedDateTextLabel.text = @"etd";
    self.estimatedDateTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedTimeArrivalLabel.text = @"/ ETA:";
    self.estimatedTimeArrivalLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.estimatedTimeArrivalTextLabel.text = @"eta";
    self.estimatedTimeArrivalTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productImage.image = [UIImage imageNamed:@"BioMass Pellets.jpg"];


    self.productRateLabel.text = @"Rate:";
    self.productRateLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.productRateTextLabel.text = @"USD 100";
    self.productRateTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];

    self.vaighaiWorldWideLabel.text = @"Shipped by Vaighai World Wide";
    self.vaighaiWorldWideLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:10];

    tableView.tableFooterView = [UIView new];

    cell.layer.borderWidth = 1.0;
    cell.layer.cornerRadius = 10;
    cell.layer.borderColor = [UIColor blackColor].CGColor;


    [cell.contentView addSubview:self.proformaInvoiceLabel];
    [cell.contentView addSubview:self.shipmentReferenceNumberLabel];
    [cell.contentView addSubview:self.shipmentReferenceNumberTextLabel];
    [cell.contentView addSubview:self.shipmentStatusDateLabel];
    [cell.contentView addSubview:self.shipmentStatusLabel];
    [cell.contentView addSubview:self.invoiceDateLabel];
    [cell.contentView addSubview:self.invoiceLabel];
    [cell.contentView addSubview:self.estimatedDateLabel];
    [cell.contentView addSubview:self.estimatedDateTextLabel];
    [cell.contentView addSubview:self.estimatedTimeArrivalLabel];
    [cell.contentView addSubview:self.estimatedTimeArrivalTextLabel];
    [cell.contentView addSubview:self.productImage];
    [cell.contentView addSubview:self.productNameLabel];
    [cell.contentView addSubview:self.productQuantityLabel];
    [cell.contentView addSubview:self.productQuantityTextLabel];
    [cell.contentView addSubview:self.productRateLabel];
    [cell.contentView addSubview:self.productRateTextLabel];
    [cell.contentView addSubview:self.productAmountLabel];
    [cell.contentView addSubview:productAmountTextLabel];
    [cell.contentView addSubview:self.vaighaiWorldWideLabel];
    //    cell.layer.shadowColor = [[UIColor blackColor] CGColor];
    //    cell.layer.shadowOffset = CGSizeMake(0.0f,0.0f);
    //    cell.layer.shadowOpacity = 0.7f;
    //    cell.layer.shadowRadius = 4.0f;
    //[cell.layer setMasksToBounds:YES];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
    // NSLog(@"you have selected %d",indexPath.row);
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [tableView setAllowsSelection:YES];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];


    tabBar = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];

    [self.navigationController pushViewController:tabBar animated:YES];

}