我有一個問題,我似乎無法看到底部。UITableView填充每一個其他發射
在我看來確實加載了代碼,我正在創建一個數組並嘗試填充表。出於某種原因,它僅在運行應用程序時每隔一段時間填充數據。
我把日誌放在viewDidLoad中,它的運行方式和viewWillAppear一樣,並輸出數組的正確計數。
此外,UITableView特定方法在工作時會被調用,並且在它不起作用時它們不會被調用。我無法弄清楚這個問題的根源。
同樣,這種情況恰好發生在50%的時間。 Theres沒有動態的數據可能會絆倒或什麼。
#import "InfoViewController.h"
@implementation InfoViewController
- (void)viewDidLoad
{
NSLog(@"Info View Loaded"); // This runs
infoList = [[NSMutableArray alloc] init];
//Set The Data //Theres 8 similar lines
[infoList addObject :[[NSMutableDictionary alloc] initWithObjectsAndKeys: @"Scrubbed", @"name", @"scrubbed", @"url", nil]];
NSLog(@"%d", [infoList count]); // This shows the count correctly every time
[super viewDidLoad];
}
-(void) viewWillAppear:(BOOL)animated
{
NSLog(@"Info Will Appear"); // This Runs
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// This WILL NOT RUN when it doesnt work, and DOES show the count when it does run
NSLog(@"Counted in numberOfRowsInSection %d", [infoList count]);
return [infoList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"ROW");
static NSString *CellIdentifier = @"infoCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = [[infoList objectAtIndex:indexPath.row] objectForKey:@"name"];
return cell;
}
@end
在您的失敗案例中調用了您的表dataSource方法的NONE嗎? (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; – gnasher 2010-05-06 20:23:00
是沒有他們。正在被呼叫。 – g00se0ne 2010-05-06 21:24:23
(1)我是否理解正確,viewDidLoad和viewWillAppear每次運行都很好,並且可以很好地填充數組,但是您的表只更新了50%的時間? (2)沒有被調用的UITableView方法,它們從哪裏調用,代碼是什麼樣的(你可以發佈它)? – progrmr 2010-05-06 22:07:26