0

私は一般的なUISplitViewController(RootViewControllerのUITableViewと詳細ビューの他のもの)を持っています

UITableViewCellsを2つの方法で変更しました。

  1. 行の高さは55です
  2. UITableViewCellsには​​、UIImageとUILabelの両方が含まれています

合計50行あります

問題: アプリを起動すると、最初の13行(表示されている行)が表示されません。空の行が表示されます。

最初の13行からスクロールして、後ろにスクロールすると…表示されます。

私が間違っていることについて何か考えはありますか?

これが私の関連するコードです(deallocのような一般的なものは省略しました)。

////////// header file /////////////////////////
#import <UIKit/UIKit.h>

@class c_cell;  // my custom UITableViewCell class (with cell height of "55")
@class DetailViewController;

@interface RootViewController : UITableViewController {
    DetailViewController *detailViewController;
    IBOutlet c_cell *cc;
    NSArray                 *cell_names;
    NSArray                 *cell_tlas;
}

@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;

@property (nonatomic, retain) IBOutlet c_cell   *cc;
@property (nonatomic, retain) NSArray *cell_names;
@property (nonatomic, retain) NSArray *cell_tlas;

@end


/////////////////  end header file /////////////////////

実装ファイル

  #import "RootViewController.h"
    #import "DetailViewController.h"
    #import "c_cell.h"


    @implementation RootViewController

    @synthesize detailViewController;

    @synthesize cc;
    @synthesize cell_names;
    @synthesize cell_tlas;


    #pragma mark View lifecycle

    - (void)viewDidLoad {
        [super viewDidLoad];
        self.clearsSelectionOnViewWillAppear = NO;
        self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);

    }

    - (void)viewWillAppear:(BOOL)animated { 
        if (!self.cell_names) {
            self.cell_names = [NSArray arrayWithObjects:
                                  @"123",
                                  @"456",
                                  @"789", nil];     // 50 records in total...not just 3 as shown here
        }

        if (!self.cell_tlas) {
            self.cell_tlas = [NSArray arrayWithObjects:
                                 @"aaa",
                                 @"bba",
                                @"cca", nil]; // 50 records in total...not just 3 as shown here
        }
    }


    #pragma mark Table view data source
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
        return 1;
    }


    - (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
        return 50;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 55;
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        c_cell *cell   = (c_cell *)[tableView dequeueReusableCellWithIdentifier:@"ccc"];  // c_cell is my custom cell class
        if (!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"c_cell" owner:self options:nil];
            cell = self.cc;
        }

        NSString *cell_string           = [self.cell_names objectAtIndex:indexPath.row];
        NSString *cell_tla              = [self.cell_tlas objectAtIndex:indexPath.row];
        NSString *cell_image_name       = [NSString stringWithFormat:@"%@.png", cell_tla];
        cell.cell_image.image           = [UIImage imageNamed:cell_image_name];
        cell.cell_label.text            = cell_string;

        return cell;
    }



    @end
4

1 に答える 1

0

viewWillAppear の下部に追加します[[self tableView] reloadData];

于 2010-06-19T00:45:37.497 に答える