Iphone 如何设置';未找到任何记录';在我看来

Iphone 如何设置';未找到任何记录';在我看来,iphone,objective-c,cocoa-touch,ios4,Iphone,Objective C,Cocoa Touch,Ios4,我正在解析xml并将其放在表视图中。。。。但是,当没有记录时,表视图仅为空。我尝试计算存储在CellForRowatineXpath中的记录的数组,但当没有记录显示时,它不会运行此方法,因此无法插入。我在哪里可以设置这个 谢谢在数字行部分,你可以把这个放进去。。它会起作用的。看看这个方法 numberOfRowsInSection: 假设您正在使用一个名为dataArray的数组来填充tableView - (NSInteger)tableView:(UITableView *)tableVi

我正在解析xml并将其放在表视图中。。。。但是,当没有记录时,表视图仅为空。我尝试计算存储在
CellForRowatineXpath
中的记录的数组,但当没有记录显示时,它不会运行此方法,因此无法插入。我在哪里可以设置这个


谢谢

在数字行部分,你可以把这个放进去。。它会起作用的。

看看这个方法

numberOfRowsInSection:

假设您正在使用一个名为dataArray的数组来填充tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if ([dataArray count] == 0) return 1;
    return [dataArray count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    if ([dataArray count] == 0) {
       cell.textLabel.text = @"No Records Found";
    } else {
        cell.textLabel.text = [dataArray objectAtIndex:indexPath.row];
    }


    return cell;
}