私には があり、UITableView
その中には 3 行しかありませんが、それらの 3 行を見ることができます。問題は空のセルです。そこに線が見えます。私はそれらの行を見たくありません。
これらの行を削除する方法はありますか?
以下は、私が探しているものの画像です。
私には があり、UITableView
その中には 3 行しかありませんが、それらの 3 行を見ることができます。問題は空のセルです。そこに線が見えます。私はそれらの行を見たくありません。
これらの行を削除する方法はありますか?
以下は、私が探しているものの画像です。
Andrey Zの返信よりもさらに簡単です: UITableView クラスで偽の tableFooterView を作成するだけです:
self.tableFooterView = [UIView new]; // to hide empty cells
とスウィフト:
tableFooterView = UIView()
UITableView
以下のコード スニペットのいずれかを使用して、 の標準の区切り線を非表示にできます。カスタム セパレーターを追加する最も簡単な方法は、UIView
高さ 1px のシンプルなものを追加することです。
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
separatorLineView.backgroundColor = [UIColor clearColor]; // set color as you want.
[cell.contentView addSubview:separatorLineView];
また
self.tblView=[[UITableView alloc] initWithFrame:CGRectMake(0,0,320,370) style:UITableViewStylePlain];
self.tblView.delegate=self;
self.tblView.dataSource=self;
[self.view addSubview:self.tblView];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
v.backgroundColor = [UIColor clearColor];
[self.tblView setTableHeaderView:v];
[self.tblView setTableFooterView:v];
[v release];
また
- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
// To "clear" the footer view
return [[UIView new] autorelease];
}
また
また、 nickfalk's answerも確認してください。これも非常に短くて役に立ちます。また、この1行を試してみてください。
self.tableView.tableFooterView = [[UIView alloc] init];
確かではありませんが、iOS 5 以降、iOS 7 まで、私が確認したすべてのバージョンの iOS で動作しています。
swift および iOS 9 の回答を更新しました。これは、.Plain
さまざまなテーブルビューで機能します。
tableView.tableFooterView = UIView()
高さ 1pxUIView
のフッターとして透明にするとうまくいきます。tableView
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1)];
v.backgroundColor = [UIColor clearColor];
[self.tableView setTableFooterView:v];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
このコードを使用して、空のセルの区切り線を削除します。
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return [UIView new];
// If you are not using ARC:
// return [[UIView new] autorelease];
}
ストーリーボードを使用している場合は、UIView をセルの下の UITableView にドラッグ アンド ドロップし、その高さを 0 に設定するだけです (iOS 8 プロジェクトでのみテスト済み)。
テーブルビューをプレーンではなくグループ化するように設定できます-これにより、外観が少し変わりますが、少なくとも余分な行が削除されます.
私はこの正確な問題を抱えていて、最終的にグループ化されたビューに変更しました。ずっと良く見えます。
これがあなたが探しているものだと思います。
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 1.0f;
}
cellForRowAtIndexPath の内部
let separatorLineView:UIView = UIView(frame: CGRectMake(0,0,self.tableview.bounds.width,0.5))
separatorLineView.backgroundColor = tableView.separatorColor
cell!.contentView.addSubview(separatorLineView)