mercredi 25 février 2015

table view custom cell trouble codings given below


in.h
#import <UIKit/UIKit.h>
#import "ScreenOne.h"



@interface FirstViewController : UIViewController <UISplitViewControllerDelegate,cellviewdelegate>
{
__weak IBOutlet UITableView *tblview;
NSMutableArray *arrayname;
NSMutableArray *proID;

}



in .m


when the array gets the data form other view controllers it will show in the custom table view cells but data are added only in particular array



#import "FirstViewController.h"
#import "Dataware.h"
#import "ScreenOne.h"
#import "CustomTableViewCell.h"

@interface FirstViewController ()

@end

@implementation FirstViewController


- (void)viewDidLoad
{
[super viewDidLoad];
arrayname = [[NSMutableArray alloc] init];
}


when the array gets the data form other view controllers it will show in the custom table view cells but data are added only in particular array



-(void)productlistView{

NSLog(@"Loaded in productlist");
arrayname = [[NSMutableArray alloc] init];
proID = [[NSMutableArray alloc] init];

NSMutableArray *arr = [[NSMutableArray alloc] init];

[arrayname addObject:arr];


NSString *queryStr = [NSString stringWithFormat:@"select expenses_id,expenses_value,date from selection_tbl"];
Dataware *dbsql = [[Dataware alloc] initDataware];
sqlite3_stmt *sqlStmt=[dbsql OpenSQL:[queryStr UTF8String]];
if(sqlStmt != nil)
while(sqlite3_step(sqlStmt) == SQLITE_ROW)
{

[proID addObject:[NSString stringWithFormat:@"%d",sqlite3_column_int(sqlStmt, 0)]];
[arr addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(sqlStmt, 1)]];
[arr addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(sqlStmt, 2)]];

}
[dbsql CloseSQL];

[tblview reloadData];
NSLog(@"Final Value:%@",arrayname);
NSLog(@"Pro Value:%@",proID);
}
#pragma mark - Table View

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrayname count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCell" owner:self options:nil];
}

[cell SelectList:[[arrayname objectAtIndex:indexPath.row] objectAtIndex:0] Date:[[arrayname objectAtIndex:indexPath.row] objectAtIndex:1]];

NSLog(@"Custom Called Now");
return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];

NSMutableArray *arr1 = [[NSMutableArray alloc] init];
[arr1 addObject:[[arrayname objectAtIndex:indexPath.row] objectAtIndex:0]];
[arr1 addObject:[[arrayname objectAtIndex:indexPath.row] objectAtIndex:1]];
[arrayname addObject:arr1];

ScreenOne* infoController = [self.storyboard instantiateViewControllerWithIdentifier:@"screenone"];

infoController.date = [NSString stringWithFormat:@"%@",[arr1 objectAtIndex:0]];
infoController.exvalue = [NSString stringWithFormat:@"%@",[arr1 objectAtIndex:1]];

NSLog(@"Arr Val:%@",[arr1 objectAtIndex:0]);
[self.navigationController pushViewController:infoController animated:YES];
}


-(void) SelectLists:(NSString *)expensesid ExpensesDate:(NSString *)date Category:(NSString *)cate Paytype:(NSString *)pay Description:(NSString *)description Primary:(NSString *)primid{

[self productlistView];

[self.navigationController popViewControllerAnimated:YES];
[tblview reloadData];
}



Aucun commentaire:

Enregistrer un commentaire