0

グループ化されたテーブルがあります。このテーブルには 2 つのルールがあります。最初の条件では、フッターにきれいな画像を表示する必要があります (これは機能します)。2 番目の条件では、フッターにテキストを表示する必要があります (これは失敗します)。titleForFooterInSectionviewForFooterInSectionを同じテーブルで使用することはできますか? また、同じセクションで同時に使用した場合、どちらが優先されますか?

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
    if (section < self.practiceLessonSet.lessons.count) {
        if ([[self.practiceLessonSet.lessons objectAtIndex:section] words].count == 1) {
            return @"No replies yet. Try the share button?";
        }
    }
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (self.practiceLessonSet.lessons.count == 0) {
        UIImageView *view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"introPractice"]];
        view.contentMode = UIViewContentModeCenter;
        return view;
    } else
        return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (self.practiceLessonSet.lessons.count == 0)
        return 278;
    else
        // WHAT SHOULD I PUT HERE?
        return [super tableView:tableView heightForFooterInSection:section]; // <-- FAILS
}
4

3 に答える 3

1

はい、どちらもご利用いただけます。私の推測では、これらの条件は、次のようになると予想されるときに満たされていないと思います。

if (section < self.practiceLessonSet.lessons.count) {
    if ([[self.practiceLessonSet.lessons objectAtIndex:section] words].count == 1) {
        return @"No replies yet. Try the share button?";
    }
}
于 2012-10-01T22:53:30.963 に答える
0

Kaleが言ったように、はい、両方を使用できるはずなので、問題の原因となっているタイトルまたはビューセクションのいずれかで条件チェックに失敗しています(いくつかのログステートメントを入れて、それらが正しいかどうかを確認してください)実際に呼び出され、停止している場所)。私の経験から、フッターまたはヘッダーのいずれかにビューとタイトルの両方がある場合、両方に値がある場合、ビューが優先されます。

于 2012-10-01T23:29:39.000 に答える