항상 잊어버린 TableView 하단의 여분의 Separator 지우기
3454 단어 iOSObjective-CtableView
소개
TableView 하단의 추가 Separator를 지우는 방법에 대한 것입니다. (Objective-C)
TableView를 사용할 때 언제나 잊어 버려 참고서나 그물을 재검토하기 때문에 써 남깁니다.
이번에는 여분의 Separator 지우기로 좁혀 있기 때문에
TableView의 구현에 관해서 자세한 것은 언급하지 않으므로 양해 바랍니다.
우선 TableView를 만들어 봅니다.
Storyboard 이용하여 작성했습니다.
Storyboard

Storyboard에서는 항상 그렇습니다.
TableView를 준비하고 TableViewCell을 추가
TableViewCell의 Reuse Identifier를 설정(이번은 "Cell"로 설정)했을 뿐.
Source code
ViewController.m#import "ViewController.h"
@interface ViewController () <UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic) NSArray *data;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"たいとるううう";
//Cellに表示する文字列
_data = @[@"hoge", @"poco", @"piyo"];
//Delegate
_tableView.delegate = self;
_tableView.dataSource = self;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.textLabel.text = _data[indexPath.row];
return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 選択状態の解除
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
실행 결과

셀은 3개뿐인데 여분의 Separator가 가득,
해결책
단 1행 추가하는 것만으로 해결할 수 버립니다!!
- (void)viewDidLoad 안에 다음 줄을 추가합니다._tableView.tableFooterView = [UIView new];
단지 이것만으로 해결 버립니다!
방금 전의 Source code의 viewDidLoad에 추가해 보면,
Source code
ViewController.m- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"たいとるううう";
//Cellに表示する文字列
_data = @[@"hoge", @"poco", @"piyo"];
//Delegate
_tableView.delegate = self;
_tableView.dataSource = self;
//下部の余分なセパレータを表示しないために、TableViewのFooterViewを生成
_tableView.tableFooterView = [UIView new];
}
실행 결과

여분의 Separator를 지울 수있었습니다.
마지막으로
이번에는 Objective-C에서 TableView 하단의 여분의 Separator를 지우는 방법에 대해 써 보았습니다.
tableFooterView를 생성하는 방법 이외에도 더 좋은 방법을 아는 분은 교수 바랍니다.
Reference
이 문제에 관하여(항상 잊어버린 TableView 하단의 여분의 Separator 지우기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/y-okudera/items/8cb536821b53ce8672bd
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Storyboard 이용하여 작성했습니다.
Storyboard

Storyboard에서는 항상 그렇습니다.
TableView를 준비하고 TableViewCell을 추가
TableViewCell의 Reuse Identifier를 설정(이번은 "Cell"로 설정)했을 뿐.
Source code
ViewController.m
#import "ViewController.h"
@interface ViewController () <UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic) NSArray *data;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"たいとるううう";
//Cellに表示する文字列
_data = @[@"hoge", @"poco", @"piyo"];
//Delegate
_tableView.delegate = self;
_tableView.dataSource = self;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.textLabel.text = _data[indexPath.row];
return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 選択状態の解除
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
실행 결과

셀은 3개뿐인데 여분의 Separator가 가득,
해결책
단 1행 추가하는 것만으로 해결할 수 버립니다!!
- (void)viewDidLoad 안에 다음 줄을 추가합니다._tableView.tableFooterView = [UIView new];
단지 이것만으로 해결 버립니다!
방금 전의 Source code의 viewDidLoad에 추가해 보면,
Source code
ViewController.m- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"たいとるううう";
//Cellに表示する文字列
_data = @[@"hoge", @"poco", @"piyo"];
//Delegate
_tableView.delegate = self;
_tableView.dataSource = self;
//下部の余分なセパレータを表示しないために、TableViewのFooterViewを生成
_tableView.tableFooterView = [UIView new];
}
실행 결과

여분의 Separator를 지울 수있었습니다.
마지막으로
이번에는 Objective-C에서 TableView 하단의 여분의 Separator를 지우는 방법에 대해 써 보았습니다.
tableFooterView를 생성하는 방법 이외에도 더 좋은 방법을 아는 분은 교수 바랍니다.
Reference
이 문제에 관하여(항상 잊어버린 TableView 하단의 여분의 Separator 지우기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/y-okudera/items/8cb536821b53ce8672bd
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"たいとるううう";
//Cellに表示する文字列
_data = @[@"hoge", @"poco", @"piyo"];
//Delegate
_tableView.delegate = self;
_tableView.dataSource = self;
//下部の余分なセパレータを表示しないために、TableViewのFooterViewを生成
_tableView.tableFooterView = [UIView new];
}
이번에는 Objective-C에서 TableView 하단의 여분의 Separator를 지우는 방법에 대해 써 보았습니다.
tableFooterView를 생성하는 방법 이외에도 더 좋은 방법을 아는 분은 교수 바랍니다.
Reference
이 문제에 관하여(항상 잊어버린 TableView 하단의 여분의 Separator 지우기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/y-okudera/items/8cb536821b53ce8672bd텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)