配列に格納されたコンテンツを入力する必要がある UITableView があります。配列を NSLog に表示しましたが、これは問題なく表示されますが、uitableview には表示されません。問題は、プログラムがcellForRowAtIndexPathメソッドに入らないことです。理解しやすくするためにこの質問にどのコードを追加すればよいかわかりませんので、コードを尋ねてください。
#import "SubList.h"
#import "SubListParser.h"
#import "LoginParser.h"
@implementation SubList
@synthesize theXML1,FolderID,UserID;
NSString *loginUserId;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
self.FolderID=FolderID ;
self.UserID=UserID;
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self initWithData];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
-(void)initWithData{
//[self GetChilds:FolderID UserID:loginUserId];
}
-(void)GetUserLoginId:(NSString *)UserIdReceved{
loginUserId=UserIdReceved;
}
-(void)GetChilds:(NSString*)FolderIDRecvd UserID:(NSString*)userID{
NSString *_FolderID=FolderIDRecvd;
NSString *_UserID=loginUserId;
//?? what to do here? aa gye bhai yha pe folder id nad user id? try out now ok
// NSLog(@"hi yaar response toh aa rha ha that mean s values toh ha hmare pass haan storyboard ka koi laucha hai ny yaar do min de dekhta hu",FolderIDRecvd,loginUserId);
NSString *soapMsg=[NSString stringWithFormat:@"<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><TreeDataSubFolder xmlns='http://tempuri.org/'><FolderID>%@</FolderID><UserId>%@</UserId></TreeDataSubFolder></soap:Body></soap:Envelope>",_FolderID,_UserID];
NSLog(@"%@",soapMsg);
NSURL *url=[NSURL URLWithString:@"http://192.168.1.5/interlogicsmobile/interlogics.asmx?op=TreeDataSubFolder"];
xmlparser1 = [[NSXMLParser alloc] initWithContentsOfURL:url];
NSMutableURLRequest *req=[NSMutableURLRequest requestWithURL:url];
NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMsg length]];
NSLog(@"Message Length=%@",msgLength);
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://tempuri.org/TreeDataSubFolder" forHTTPHeaderField:@"SOAPAction"];
[req addValue:@"length" forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
//[activityIndicator startAnimating];
conn1=[[NSURLConnection alloc]initWithRequest:req delegate:self];
if(conn1){
webdata1=[NSMutableData data] ;
}
}
-(void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *) response {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
int responseStausCode = [httpResponse statusCode];
NSLog(@"code: %d", responseStausCode);
[webdata1 setLength: 0];
}
-(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data {
[webdata1 appendData:data];
}
-(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error {
}
-(void) connectionDidFinishLoading:(NSURLConnection *) connection {
NSLog(@"DONE. Received Bytes: %d", [webdata1 length]);
theXML1 = [[NSString alloc]
initWithBytes: [webdata1 mutableBytes]
length:[webdata1 length]
encoding:NSUTF8StringEncoding];
//---shows the XML---
//NSLog(@"%@",theXML1);
SubListParser *parserObjForData1=[[SubListParser alloc]init];
SubFolderData=[[NSMutableArray alloc]init];
SubFolderData=[parserObjForData1 UserXMLParser1:webdata1];
[SublistSet reloadData];
}
- (void)viewDidUnload
{
[SublistSet reloadData];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[SublistSet reloadData];
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [SubFolderData count]/2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"*******************called tablevied did load*********************");
int row = [indexPath row]*2;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
for (int i=0; i<=[SubFolderData count]/2; i++) {
NSString *filename = [SubFolderData objectAtIndex:row];
NSString *ext = [filename pathExtension];
if ([ext isEqualToString:@"doc"] || [ext isEqualToString:@"DOC"]) {
[cell.imageView setImage:[UIImage imageNamed:@"DOC.png"]];
} else if ([ext isEqualToString:@"jpg"]|| [ext isEqualToString:@"JPG"]) {
[cell.imageView setImage:[UIImage imageNamed:@"JPG.png"]];
}else if([ext isEqualToString:@"pdf"]|| [ext isEqualToString:@"PDF"]){
[cell.imageView setImage:[UIImage imageNamed:@"PDF.png"]];
}else if([ext isEqualToString:@""]){
[cell.imageView setImage:[UIImage imageNamed:@"Folder2.png"]];
}else if([ext isEqualToString:@"docx"]|| [ext isEqualToString:@"DOCX"]){
[cell.imageView setImage:[UIImage imageNamed:@"DOCX.png"]];
}else if([ext isEqualToString:@"TIF"]|| [ext isEqualToString:@"tif"]){
[cell.imageView setImage:[UIImage imageNamed:@"TIFF.png"]];
}else if([ext isEqualToString:@"png"]|| [ext isEqualToString:@"PNG"]){
[cell.imageView setImage:[UIImage imageNamed:@"PNG.png"]];
}else if([ext isEqualToString:@"gif"]|| [ext isEqualToString:@"GIF"]){
[cell.imageView setImage:[UIImage imageNamed:@"GIF.png"]];
}else if([ext isEqualToString:@"jpeg"]|| [ext isEqualToString:@"JPEG"]){
[cell.imageView setImage:[UIImage imageNamed:@"JPG.png"]];
}
}
// Configure the cell...
cell.textLabel.text=[SubFolderData objectAtIndex:row];
cell.detailTextLabel.text =[SubFolderData objectAtIndex:row+1];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
return cell;
}
/*
// Override to support conditional editing of the table view.
@end