-
Notifications
You must be signed in to change notification settings - Fork 5
Trouble Shooting
์ ํฌ ์กฐ๋ ์ฒ์์ edit mode๋ผ๋ ๊ฑธ ๋ชฐ๋ผ์ ๋ค๋น๊ฒ์ด์ ๋ฐ ๋ฒํผ์ ๋๋ ์ ๊ฒฝ์ฐ, ๋ค์ค ์ ํ์ ์ํ ๋ฒํผ์ ์ถ๊ฐ ์ํค๊ธฐ ์ํด registration์ ์ฌ์ค์ ํด์ ๋ทฐ๋ฅผ ๋ค์ ๊ทธ๋ ค์คฌ์ต๋๋ค.
๋ํ.. ์ด๋ ๊ฒ ํด์ฃผ๋๊น swipeํด์ delete ๋ฒํผ์ ํ์ํด์ฃผ๋ ๊ธฐ๋ฅ์ด ๋ค์ด๊ฐ ์์ด์ ๋ค์ค ์ ํ ์ค์๋ swipeํ๋ฉด delete ๋ฒํผ์ด ๋ํ๋๋ ๋์ฐํ ํผ์ข ์ด ํ์ํด๋ฒ๋ ธ์ต๋๋ค... ๐คฏ
์ด ๋ถ๋ถ์์ ๋ฉ๋ชจ๋ฆฌ ๋์๊ฐ ๋ฐ์ํ๊ณ , ์ ์์ ์ธ ๋ฐฉ์์ด ์๋๋ผ๊ณ ์๊ฐ์ด ๋์์ต๋๋ค.
![](https://user-images.githubusercontent.com/31726630/98321604-ddfc1d00-2028-11eb-8f8a-a3d6267e8b64.png)
< inset์ ๋ฃ์ด์ค์ view ์์น๋ฅผ ์ด๋์์ผฐ๋๋ .. ๋์ฐํ ํผ์ข ์ด ํ์ํ์ต๋๋ค.jpg >
๋ฒํผ์ด ์์ฑ๋ ๋, ์๋๋ฉ์ด์ ๋ ์ค์ ์ด ๋ถ๊ฐ๋ฅํ๊ณ edit ๋ฒํผ์ ๋ค์ ๋๋ ์ ๋์๋ ์ ํ ๋ฒํผ์ด ์ฌ๋ผ์ง์ง์๋ ๋ฌธ์ ๊น์ง ๋ฐ์ํ์ต๋๋ค.
์ด๊ฑธ ์ง์ ์กฐ์ ํ๋ ค๋ค๋ณด๋ ๋ฌธ์ ๊ฐ ์๊ธด ๊ฒ ๊ฐ์์ ๊ทผ๋ณธ์ ์ธ ๋ฌธ์ ๋ก ๋์๊ฐ์ต๋๋ค.
CollectionViewListCell์์ acceesoies๋ฅผ ์ถ๊ฐ ํ ๋, accessory๊ฐ ๋ณด์ฌ์ง๋ ์์ ์ ์ ์ ํ ์ ์๋๋ฐ, whenEditing์ด๋ผ๋ ์ต์ ์ด ์์์ต๋๋ค.
์! ๊ทธ๋ฌ๋ฉด "collectionView์๋ editing mode๊ฐ ์๊ฒ ์ง..?" ๋ผ๋ ๊ฒฐ๋ก ์ ๋๋ฌํ์ต๋๋ค.
๊ทธ๋์ collectionView์ ๋ด์ฅ ๋์ด์๋ isEditing์ด๋ผ๋ ๋ฉ์๋๋ฅผ ์์๋์ต๋๋ค.
์ ๋ ์นด! ํ์ง๋ง ์ฌ๊ธฐ์ ๋ง์กฑํ์ง ์์์ต๋๋ค. ์ด ๋ถ๋ถ์ ์ฐพ๋ค๋ณด๋ ์์ฒด์ ์ผ๋ก ์ด๋ฏธ ๊ตฌํ์ด ๋์ด์๋ editButtonItem์ด ์๋ค๋ ๊ฒ์ ์๊ฒ ๋์๊ณ , ์ด ๋ฒํผ์ ํตํด edit ์ ํ์ ํ ์ ์๋ ๊ฒ์ ์๊ฒ ๋์์ต๋๋ค.
์๋์ ๊ฐ์ด, viewDidLoad์์ ๋ณ๋ค๋ฅธ ์ ์ธ ์์ด ๊ฐ๋จํ๊ฒ ๋ฒํผ์ ์ถ๊ฐ์ํฌ ์ ์์์ต๋๋ค.
navigationItem.rightBarButtonItem = editButtonItem
์ด setEditing ๋ฉ์๋๋ฅผ ์ค๋ฒ๋ผ์ด๋ํด์ editButtonItem๋ฅผ ํฐ์นํ๋ฉด ํ๋ผ๋ฏธํฐ์ editing์ด ๋ฐ์๋์ด ์๋์ผ๋ก edit mode๋ฅผ ์กฐ์ ํ ์ ์์์ต๋๋ค.
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
collectionView.isEditing = editing
collectionView.allowsSelectionDuringEditing = editing
collectionView.allowsMultipleSelectionDuringEditing = editing
}
.. ์ด์๋ค..
- ์์ VC์ bottom card VC์ embedํ๋ ๋ฐฉ์์ผ๋ก ํด๊ฒฐํ๋ ค๊ณ ํจ. (์๋ ์ฝ๋ ์ฐธ์กฐ)
addChild(bottomVC)
bottomVC.view.frame = CGRect(origin: .zero, size: view.frame.size)
view.addSubview(bottomVC.view)
bottomVC.didMove(toParent: self)
- ํ์ง๋ง, ์๋จ navigation bar์ ๊ฐ๋ ค์ง๋ ํ์์ด ๋ฐ์ํจ.
- Key Window ํ์ฉ
- key window์ bottom card view๋ฅผ ์ฝ์
var bottomViewController: IssueDetailBottomViewController?
func configureBottomView() {
guard let bottomVC = storyboard?.instantiateViewController(identifier: "issueDetailBottomVC")
as? IssueDetailBottomViewController
else { return }
bottomViewController = bottomVC
let window = UIApplication.shared.windows.filter { $0.isKeyWindow }.first
window?.addSubview(bottomVC.view)
}
- ํด๊ฒฐ! Bottom view๊ฐ navigation bar ์๋ก ๋ณด์ฌ์ง.