2011-10-19 1 views
0

私はiphoneのアプリケーション開発に新しい午前はそう誰も助けてくださいme.my主な問題は、XML解析されたデータを表示するためのUITableViewの行数はいくらですか?

される - >の後、私はnsmutable配列の目的であるにNSArrayにNSArrayでのXMLの属性値を挿入していたXMLを解析されました。そのような何か...

[records addObject:[NSArray arrayWithObjects: 
          [TBXML textForElement:visitor], 
          [TBXML textForElement:uniqueVisitor], 
          [TBXML textForElement:order], 
          [TBXML textForElement:revenue], 
          [TBXML textForElement:conversionRate], 
          [TBXML textForElement:newProduct], 
          [TBXML textForElement:outOfStockProduct], 
          [TBXML textForElement:productInCart], 
          [TBXML textForElement:visitorInc], 
          [TBXML textForElement:uniqueVisitorInc], 
          [TBXML textForElement:orderInc], 
          [TBXML textForElement:revenueInc], 
          [TBXML textForElement:conversionRateInc], 
          [TBXML textForElement:newProductInc], 
          [TBXML textForElement:outOfStockProductInc], 
          [TBXML textForElement:productInCartInc],nil]]; 

今、私はセクション内の行数は、いずれかをmethod.pleaseされるかわからないuitableview.butのすべてのセル内の各属性値を一さようなら1を表示したいですボディme.iは、サンプルコードを与えているに役立つ....

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section{ 
    NSLog(@"The number of row in the object array: %d ",[records count]); 
return [records count]; 
    } 

テーブルビューの方法は、すべてのセル内のすべての属性値1つの不戦勝1を表示するための戻り値の型がどうなるかを教えて...今ここにあります。

ありがとうございました。

答えて

0

あなたは、各フィールドのラベルを作成し、cellForRowAtIndexPath、アウトラインビーイングのセルにそれを追加することができます。もちろん

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

cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

// THIS CREATES THE CELL 
NSInteger index = (page-1)*pagesize + indexPath.row; 
NSDictionary* dataAtIndex = [records getDataAtIndex:index]; 
if (cell == nil) { 
    cell = [[[myTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:CellIdentifier] autorelease]; 

    int x = 0; 
    int cellsize = 50; 
    int padding = 1; 
    int nbxmlrecords = [[records objectAtIndex:indexPath.row] count]; 

    for (int idx = 0 ; idx < nbxmlrecords; idx++) 
    { 
      UILabel* aLabel = [[[UILabel alloc] initWithFrame:CGRectMake(x, 0.0, 
                     cellsize, cell.contentView.frame.size.height)] autorelease]; 
      x = x + cellsize + padding; 

      aLabel.tag = idx; 
      aLabel.font = [UIFont systemFontOfSize:10.0]; 
      aLabel.textAlignment = UITextAlignmentLeft; 
      aLabel.textColor = [UIColor blackColor]; 
      aLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
      aLabel.opaque = true; 

      [cell.contentView addSubview:aLabel]; 
    } 
} 

// THIS FILLS THE DATA IN THE CELL 
for (int idx = 0 ; idx < nbxmlrecords; idx++) 
{ 
     NSString* value = [[records objectAtIndex:indexPath.row] objectAtIndex:idx]; 
     UILabel* aLabel = (UILabel *)[cell.contentView viewWithTag:idx]; 
     aLabel.text = value; 
} 

... 

を、あなたは、各フィールドのサイズとで全体の長さを作業する必要がありますスクリーン。

関連する問題