我正在使用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];
}
现在amountArray
有两个不同的值。
在cellForRowAtIndexPath
中,我尝试将这些值设置如下,
- (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;
}
self.productAmountLabel = [[UILabel alloc]init];
self.productAmountTextLabel = [[UILabel alloc]init];
if (IS_IPHONE_4_OR_LESS || IS_IPHONE_5)
{
self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
self.productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
}
else if (IS_IPHONE_6)
{
self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
self.productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
}
else if (IS_IPHONE_6P)
{
self.productAmountLabel.frame = CGRectMake(75, 145, 100, 30);
self.productAmountTextLabel.frame = CGRectMake(117, 145, 100, 30);
}
self.productAmountLabel.text = @"Amount:";
self.productAmountLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];
// self.productAmountTextLabel.text = [NSString stringWithFormat:@"%@",amountArray[indexPath.row]];
// self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];
self.productAmountTextLabel.text = amountArray[indexPath.row];
self.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:self.productAmountLabel];
[cell.contentView addSubview:self.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;
}
问题是,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];
}
答案 0 :(得分:1)
在cellForRowAtIndexPath中,删除for循环。因为如果你在cellForRowAtIndexPath中执行循环,那么总是最后一个值将显示在每个单元格中。
self.productAmountTextLabel.text = amountArray[i];
self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];
答案 1 :(得分:1)
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];
}