Notice
Recent Posts
Recent Comments
Link
ยซ   2024/05   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

lgvv98

[iOS] UITableView BackgroundView didTapped โœจ ๋ณธ๋ฌธ

โš ๏ธ deprecated โš ๏ธ/Calendar

[iOS] UITableView BackgroundView didTapped โœจ

๐Ÿฅ• ์บ๋Ÿฟ๋งจ 2022. 5. 4. 15:21

UITableView BackgroundView didTapped

 

โœ… ์ด๋ฒˆ์—๋Š” ํ…Œ์ด๋ธ” ๋ทฐ์—์„œ ์…€ ๋ฐ”๊นฅ ๋ถ€๋ถ„์˜ ํ„ฐ์น˜๋ฅผ ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž.

ํ…Œ์ด๋ธ” ๋ทฐ์™€ cell

 

โœ… ๋‚ด๊ฐ€ ํ•ด๊ฒฐํ•œ ๋ฐฉ๋ฒ•์˜ ์ฝ”๋“œ๋Š” ์ƒ๊ฐ๋ณด๋‹ค ๊ฐ„๋‹จํ–ˆ๋Š”๋ฐ

let tableView = UITableView()

let didTapView = UITapGestureRecognizer(
    target: self,
    action: #selector(didTapView)
)

tableView.backgroundView = UIView()
tableView.backgroundView?.addGestureRecognizer(didTapView)

@objc
func didTapView() {
    print("DidTap")
    dismiss(animated: false, completion: nil)
}

 

stackOverflow์—์„œ ํ•ด๋‹ต์„ ์ฐพ์•˜๋‹ค.

https://stackoverflow.com/questions/24141254/how-to-detect-tap-on-clear-part-of-uitableview

 

How to detect tap on clear part of UITableView?

I have view controller with UITableView. Height of table view is static and == height of screen. Number of rows in table can change and sometimes it might be a situation when number of rows is less...

stackoverflow.com

 

โœ… ๋‹ค๋งŒ ๋‚ด๊ฐ€ ์ง„์งœ ํ•˜๊ณ  ์‹ถ์€๊ฑด ํ…Œ์ด๋ธ” ๋ทฐ์˜ ์…€์˜ ๊ฐฏ์ˆ˜์™€ ๋†’์ด๋ฅผ ๊ณ„์‚ฐํ•˜์—ฌ tableView ์ž์ฒด์˜ constraints๋ฅผ height์— ๋งž๊ฒŒ๋” ํ•˜์—ฌ backgroundView๊ฐ€ ๋‚˜ํƒ€๋‚˜์ง€ ์•Š๊ฒŒ๋” ๋งŒ๋“ค๊ณ  ์‹ถ์—ˆ๋Š”๋ฐ, ๊ทธ๊ฑด ์–ด๋–ป๊ฒŒ ํ•˜๋Š”์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค.

 

ํ˜น์‹œ๋ผ๋„ ์•„๋Š” ์‚ฌ๋žŒ์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€ ๋ฐ”๋ž๋‹ˆ๋‹ค:)

Comments