UITable View 아래에 추가 구분 기호 제거
4개의 행으로 테이블 뷰를 설정해도 채워진 행 아래에 여분의 구분선(또는 여분의 공백 셀)이 있습니다.
이 세포들은 어떻게 제거하나요?
인터페이스 빌더(iOS 9+)
UIView를 테이블로 끌어다 놓기만 하면 됩니다.스토리보드에서는 커스텀 셀 아래 맨 위에 배치됩니다."footer"라는 이름을 붙이는 것이 좋습니다.
여기에 녹색으로 표시되어 있어 선명한 색상을 원할 수 있습니다.
높이를 조정하면 원하는 대로 테이블의 "하단 바운스" 처리 방법에 영향을 줄 수 있습니다(높이 0은 보통 좋습니다).
프로그래밍 방식으로 실행하려면:
재빠르다
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.tableFooterView = UIView()
}
목표-C
iOS 6.1+
- (void)viewDidLoad
{
[super viewDidLoad];
// This will remove extra separators from tableview
self.tableView.tableFooterView = [UIView new];
}
원하신다면
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
iOS의 과거 기록:
테이블 뷰 컨트롤러에 추가...
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return CGFLOAT_MIN;
}
필요하다면...
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return [UIView new];
// If you are not using ARC:
// return [[UIView new] autorelease];
}
그룹화된 테이블 스타일을 사용하지 않는 다른 방법이 있습니다.그것은 아마 추측할 수 없는 방법입니다.추가 중
머리글과 테이블 바닥글
(이쪽이나 다른쪽은 체크하지 않았습니다) 를 지정하면 세퍼레이터가 필러/공백 행에서 사라집니다.
손가락이 단단한 테이블 셀 대신 테이블 상단과 하단의 작은 공간을 확보하여 버튼을 누를 위험을 줄이고 싶었기 때문에 우연히 알게 되었습니다.빈 뷰를 머리글과 바닥글로 고정하는 방법은 다음과 같습니다.원하는 높이를 사용해도 추가 구분선은 여전히 제거됩니다.
- (void) addHeaderAndFooter
{
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
v.backgroundColor = [UIColor clearColor];
[self.myTableView setTableHeaderView:v];
[self.myTableView setTableFooterView:v];
[v release];
}
@Casebash에 응답하여 앱의 코드(iTunes 스토어의 AcmeLists' List Manager...)로 돌아가서 addHeaderAndFooter 메서드를 단락하여 확인했습니다.이 기능이 없으면 추가 행 구분 기호가 있습니다. 코드를 사용하면 이 창 스냅에 표시되는 내용을 볼 수 있습니다. 테이블 행 구분 기호가 없습니다.그래서 왜 너한테 안 먹혔는지 모르겠어.게다가 테이블 뷰에 커스텀 푸터가 있는 경우 테이블 뷰 아래의 빈 행에 대해 행 구분 기호를 그리는 것을 반드시 중지해야 합니다.그건 끔찍할 거야.참고로 화면에서 볼 수 있는 것보다 더 많은 행이 있는 테이블을 보고 두 행이 있는 테이블을 보았습니다.두 경우 모두 외부 분리기는 사용하지 마십시오.
사용자 지정 보기가 실제로 추가되지 않았을 수 있습니다.하려면 , 을 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , .clearColor
,190),[UIColor redColor]
테이블 하단에 빨간색 막대가 표시되지 않으면 바닥글이 설정되어 있지 않습니다.
Swift의 UITableView에서 빈 행에 대한 추가 구분 기호 제거
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.yourTableview.tableFooterView = UIView()
}
wkw 답변을 연장하고 싶습니다.
높이가 0인 바닥글만 추가하면 됩니다.(sdk 4.2, 4.4.1에 탑재)
- (void) addFooter
{
UIView *v = [[UIView alloc] initWithFrame:CGRectZero];
[self.myTableView setTableFooterView:v];
}
또는 테이블 뷰를 설정하는 위치에 다음 행을 추가합니다.
//change height value if extra space is needed at the bottom.
[_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)]];
또는 더 단순하게 - 구분자를 제거합니다.
[_tableView setTableFooterView:[UIView new]];
다시 wkw 덕분에 :)
스토리보드를 사용하는 iOS 7+용
만 하면 .UIView
의 에 your에UITableView
바닥글로 사용합니다.0으로 하다
이거 먹어봐.나한테는 효과가 있었어.
- (void) viewDidLoad
{
[super viewDidLoad];
// Without ARC
//self.tableView.tableFooterView = [[[UIView alloc] init] autorelease];
// With ARC, tried on Xcode 5
self.tableView.tableFooterView = [UIView new];
}
Swift를 사용하는 경우 테이블 뷰를 관리하는 컨트롤러의 viewDidLoad에 다음 코드를 추가합니다.
override func viewDidLoad() {
super.viewDidLoad()
//...
// Remove extra separators
tableView.tableFooterView = UIView()
}
Swift의 경우:
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView()
}
맨 끝에 빈 바닥글을 추가하면 빈 셀이 숨겨지지만 보기에도 좋지 않습니다.
tableView.tableFooterView = UIView()
더 나은 방법이 있습니다. 바닥글을 사용하여 테이블 뷰 끝에 1개의 점선을 추가하면 빈 셀도 더 이상 표시되지 않습니다.
let footerView = UIView()
footerView.frame = CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 1)
footerView.backgroundColor = tableView.separatorColor
tableView.tableFooterView = footerView
이 코드(Swift)를 추가합니다.
tableView.tableFooterView = UIView()
J. Costa의 솔루션 발전:다음 코드 행을 입력하면 테이블을 글로벌하게 변경할 수 있습니다.
[[UITableView appearance] setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
한 첫 방법은 「」에서)의 내부(통상은 「」로)AppDelegate
, 인:application:didFinishLaunchingWithOptions:
★★★★★★★★★★★★★★★★★★」
Swift는 다음과 같은 기능을 제공합니다.
tableView.tableFooterView = UIView()
, 이 은 다른 .UITableView
.
수 .tableView
의 표준 구분줄과 각 셀의 맨 위에 커스텀 행을 추가합니다.
업데이트:
은 간단한 세퍼레이터를 입니다.UIView
§ 1px:
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
separatorLineView.backgroundColor = [UIColor grayColor]; /// may be here is clearColor;
[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];
}
아니면 내가 좋아하는 가장 단순하고 좋은 방법은
self.tableView.tableFooterView = [[UIView alloc] init];
어느쪽이든 시험해 보세요.
당신은 이 질문에 대한 많은 답을 찾을 수 있을 것이다.은 조작을 으로 하고 있습니다.UITableView
의 »tableFooterView
빈 행을 숨기려면 이 방법을 사용합니다.편의상 Interface Builder에서 빈 행을 켜거나 끌 수 있는 간단한 확장을 만들었습니다.이 gist 파일에서 확인할 수 있습니다.시간이 좀 절약됐으면 좋겠어요.
extension UITableView {
@IBInspectable
var isEmptyRowsHidden: Bool {
get {
return tableFooterView != nil
}
set {
if newValue {
tableFooterView = UIView(frame: .zero)
} else {
tableFooterView = nil
}
}
}
}
사용방법:
tableView.isEmptyRowsHidden = true
uitableview 추가 구분 기호 행 숨기기 swift 3.0에서 추가 구분 기호 행 숨기기
self.tbltableView.tableFooterView = UIView(frame: .zero)
마지막 셀 뒤에 구분 기호를 사용하지 않으려면 바닥글 높이가 0에 가깝지만 0이 아닌 높이가 필요합니다.
고객님의 고객명UITableViewDelegate
:
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return .leastNormalMagnitude
}
원하는 세퍼레이터 색상의 뷰를 배경색, 폭 100%, 높이 1px(x0 y-1 위치)로 테이블에 추가합니다.ViewCelltableViewCell이 서브뷰를 클리핑하지 않고 tableView가 서브뷰를 클리핑하지 않는지 확인합니다.
따라서 코드나 IB별로 해킹을 하지 않고 기존 셀 사이에서만 단순하고 작동 가능한 분리기를 사용할 수 있습니다.
참고: 수직 상단 바운스에서는 첫 번째 세퍼레이터가 표시되지만 기본 iOS 동작이기 때문에 문제가 없습니다.
테이블 뷰를 사용하여 고정 높이 열을 표시했기 때문에 크기를 조정하여 스크롤할 수 없도록 했습니다.
UItableview의 하단에서 프로그래밍 방식으로 추가 구분 기호를 제거하려면 코드 두 줄 뒤에 적기만 하면 추가 구분 기호를 제거할 수 있습니다.
tableView.sectionFooterHeight = 0.f;
tableView.sectionHeaderHeight = 0.f;
이 트릭은 항상 나한테 효과가 있어, 직접 해봐.
수락된 답변의 한 부분(iOS 9+, Swift 2.2)을 구현한 것은 행운이었습니다.저는 다음과 같은 구현을 시도했습니다.
self.tableView.tableFooterView = UIView(frame: .zero)
하지만, 제겐 아무런 영향이 없었습니다.tableView
이 있을 것요. - 아, 제가 쓰던 거랑요. - 가사 - - - - - - - - - - - - - - 。UITableViewController
.
그 대신, 난 단지 이 모든 것을 덮어쓰기만 하면 되었다.viewForFooterInSection
(메서드를 )tableFooterView
( ) :
override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView(frame: .zero)
}
이 방법은 잘 작동했습니다.tableView
(여러 섹션이 있는 경우 마지막 섹션을 지정해야 합니다).
섹션이 하나만 있는 경우, 표 보기 유형을 "일반"에서 "그룹화"로 설정하는 것이 가장 빠르고 쉬운 방법입니다.(이미지 참조)
섹션이 더 많을 경우 헤더 높이를 0으로 설정해야 할 수 있습니다(고객의 취향에 따라 다름).
더 많은 섹션이 있어 헤더를 조작하고 싶지 않은 경우(가장 단순한 경우 한 줄이라도) 이전 답변에서 설명한 바와 같이 UIView를 바닥글로 설정해야 합니다.
Swift 4.0 확장
스토리보드의 간단한 확장입니다.
extension UITableView {
@IBInspectable
var hideSeparatorForEmptyCells: Bool {
set {
tableFooterView = newValue ? UIView() : nil
}
get {
return tableFooterView == nil
}
}
}
빠르고 쉬운 Swift 4way.
override func viewDidLoad() {
tableView.tableFooterView = UIView(frame: .zero)
}
정적 셀이 있는 경우.Inspector 창에서 세퍼레이터를 끌 수도 있습니다.(세퍼레이터가 필요한 경우는 바람직하지 않습니다.이 경우 상기의 사용방법)
이것으로 시험해봐
목적 C의 경우
- (void)viewDidLoad
{
[super viewDidLoad];
// This will remove extra separators from tableview
self.yourTableView.tableFooterView = [UIView new];
}
스위프트의 경우
override func viewDidLoad() {
super.viewDidLoad()
self.yourTableView.tableFooterView = UIView()
}
UITableview에서 불필요한 공간을 제거하려면 다음 두 가지 방법을 사용할 수 있습니다.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.1;
}
이 작은 테이블 뷰 확장을 추가했습니다.
extension UITableView {
func removeExtraCells() {
tableFooterView = UIView(frame: .zero)
}
}
Swift 3 / Swift 4 / Swift 5 + 매우 쉽고 심플한 방법
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//MARK:- For Hiding the extra lines in table view.
tableView?.tableFooterView = UIView()
}
또는
override func viewDidLoad(_ animated: Bool) {
super.viewDidLoad(animated)
//MARK:- For Hiding the extra lines in table view.
tableView?.tableFooterView = UIView()
}
이거 드셔보세요
self.tables.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 10.0f)];
UIKit
빈 셀을 작성하지 않습니다.tableView
가 있다tableFooterView
그럼 트릭을 만들어서 높이를 0으로 지정할 수 있습니다.UIView
의 바닥글로서 오브젝트tableView
.
tableView.tableFooterView = UIView()
가지고 계신 경우searchbar
당신의 안에서view
(예를 들어 결과 수를 제한하려면)에 다음 항목도 추가해야 합니다.shouldReloadTableForSearchString
그리고.shouldReloadTableForSearchScope:
controller.searchResultsTable.footerView = [ [ UIView alloc ] initWithFrame:CGRectZero ];
언급URL : https://stackoverflow.com/questions/1369831/eliminate-extra-separators-below-uitableview
'programing' 카테고리의 다른 글
기존 ASP에 웹 API를 추가하는 방법.NET MVC (5) 웹 애플리케이션 프로젝트? (0) | 2023.04.27 |
---|---|
백그라운드 프로세스를 포킹/실행하기 위한 bash 앰퍼샌드(&)와 동등한 Powershell (0) | 2023.04.22 |
배리언트 배열에 범위를 할당하는 데 문제가 발생하는 이유 (0) | 2023.04.22 |
Azure 웹사이트의 사이트에서 X509 Certificate 2 처리가 실패함 (0) | 2023.04.22 |
Excel 선택과 활성화 (0) | 2023.04.22 |