Skip to content

Trouble Shooting iOS

woongs edited this page Nov 26, 2020 · 2 revisions

Trouble Shooting

Contents


Nov 19, 2020

Task, Class vs Struct

  • ์ด์Šˆ: ํ•  ์ผ์ด ๋˜๋Š” Task ๋ฅผ Struct ๋กœ ํ•  ๊ฒƒ์ธ๊ฐ€, Class๋กœ ํ•  ๊ฒƒ์ธ๊ฐ€.
  • ๊ฒฐ๋ก : Task๋Š” Class ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ๊ฒฐ์ •
  • ์ด์œ 
    • Task๋Š” ํ•˜์œ„์— ๋˜ Task๋ฅผ ๋‘๋Š” ํŠธ๋ฆฌ๊ตฌ์กฐ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋Š”๋ฐ, Struct๋กœ ํ•  ๊ฒฝ์šฐ ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•ด๋„ ์ „์ฒด๋ฅผ ๋‹ค ๋ณ€๊ฒฝํ•ด์ค˜์•ผ ํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์Œ.
    • ๋˜ Task๋Š” ํ•˜๋‚˜์˜ ํ”„๋กœ์ ํŠธ ๋ฟ ์•„๋‹ˆ๋ผ ๊ธฐ๊ฐ„, ๋ผ๋ฒจ ๋“ฑ์— ์˜ํ•ด ์—ฌ๋Ÿฌ ๋ถ€๋ถ„์—์„œ ์‚ฌ์šฉ๋จ. ๋”ฐ๋ผ์„œ ๊ณ„์† ๋ณต์‚ฌํ•˜๊ธฐ๋ณด๋‹ค ์ฐธ์กฐ ํ˜•ํƒœ๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ํšจ์œจ์ ์ด๋ผ๊ณ  ํŒ๋‹จํ•จ.
    • ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•ด์ค„ ๋•Œ parent์™€ children์˜ ๋ณ€๊ฒฝ์ด ๋นˆ๋ฒˆํžˆ ์ผ์–ด๋‚˜๊ธฐ ๋•Œ๋ฌธ์— ์ฐธ์กฐ๋ฅผ ํ†ตํ•ด ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” class๊ฐ€ ๋” ์ ํ•ฉํ•˜๋‹ค๊ณ  ํŒ๋‹จ.

UICollectionViewDropDelegate wrong destination index path in dropSessionDidUpdate

func collectionView( _ collectionView: UICollectionView, dropSessionDidUpdate session: UIDropSession,
    withDestinationIndexPath destinationIndexPath: IndexPath?)
    -> UICollectionViewDropProposal 

์œ„ ํ•จ์ˆ˜๋Š” cell์„ dragํ• ๋•Œ cell์˜ drag์œ„์น˜๊ฐ€ ๋ณ€๊ฒฝํ•  ๋•Œ ๋งˆ๋‹ค collectionview ๋‚ด์˜ cell์œ„์น˜๋ฅผ 'proposal'ํ•˜๋Š” ์—ญํ• ์„ ํ•˜๊ณ  ์žˆ์œผ๋ฉฐ destinationIndexPath๋Š” cell์ด ์œ„์น˜ํ•˜๋Š” indexPath๋ฅผ ์˜๋ฏธํ•œ๋‹ค.

  • ์ด์Šˆ: destinationIndexPath๊ฐ€ ๋‹ค๋ฅธ ์œ„์น˜๋กœ ๊ฐ€๋„ ๊ฐ™์€๊ฐ’์„ ์œ ์ง€ํ•˜๊ฑฐ๋‚˜ ๊ฐ€๋” ๋ฐ”๋€Œ๊ฑฐ๋‚˜ ์›€์ง์ž„์— ๋งž์ง€ ์•Š๋Š” ๊ฐ’์„ ์ถœ๋ ฅํ•œ๋‹ค.
  • ๊ฒฐ๋ก : session.location์„ ํ†ตํ•ด ์ •ํ™•ํ•œ destination indexpath๋ฅผ ์•Œ์•„๋‚ธ๋‹ค.
		// Calculating location in view
    let location = session.location(in: collectionView)
    var correctDestination: IndexPath?
    // Calculate index inside performUsingPresentationValues
    collectionView.performUsingPresentationValues {
        correctDestination = collectionView.indexPathForItem(at: location)
    }
  • ์ด์œ 
    • UIKit์˜ ๋ฒ„๊ทธ๋ผ๋Š” ์˜๊ฒฌ..
    • collectionView ์•ˆ์—์„œ์˜ ์ƒ๋Œ€์ ์ธ index path๋ฅผ ๊ตฌํ•œ๋‹ค.
    • Apple Developer ๋ฌธ์„œ ์ •์˜
      • performUsingPresentationValues(_:) Execute actions on the current object using index paths that are relative to the presentation layer of that object.

Nov 20, 2020

Drag and Drop with DiffableDataSource

1. reorder Accessory ์—†์ด reorder ํ•˜๊ธฐ

  • ์ด์Šˆ
    • DiffableDataSource์—์„œ ๊ฐ์‚ฌํ•˜๊ฒŒ๋„ reorder ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ด์ฃผ์ง€๋งŒ ์˜ˆ์ œ๋ฅผ ๋ณด๋ฉด reorder accessory๋ฅผ ์ด์šฉํ•ด์„œ๋งŒ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ๊ฒŒ ๋˜์–ด์žˆ๋‹ค.
    • ์—†์ด ๊ทธ๋ƒฅ ์…€์„ ๋ฐ”๋กœ ํ•  ์ˆ˜๋Š” ์—†์„๊นŒ??
  • ๊ฒฐ๋ก 
    • ๊ธฐ์กด์˜ CollectionView์—์„œ ์‚ฌ์šฉํ•˜๋˜ ๋ฐฉ์‹ ๋Œ€๋กœ UICollectionViewDragDelegate ์™€ UICollectionViewDropDelegate ๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉด ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค!
    • reorder ๋˜๊ณ  ๋‚˜๋ฉด dataSource์˜ reorderingHandlers ๋„ ๋ถˆ๋ฆฌ๋Š” ๊ฒƒ์„ ํ™•์ธ
  • ์ด์œ 
    • ์ž‘์—… ์…€์ด ์ ‘ํžˆ๊ณ  ํŽผ์ณ์ง€๋Š” ๊ธฐ๋Šฅ์ด ํ•„์š”ํ•œ๋ฐ reorder ์•…์„ธ์‚ฌ๋ฆฌ๊นŒ์ง€ ๊ฐ™์ด ์žˆ์œผ๋ฉด ๋ณ„๋กœ ์˜ˆ์˜์ง€๊ฐ€ ์•Š๊ณ  ๋ถˆํŽธํ•ด์„œ, ๊ธฐ์กด์˜ ๋ฐฉ์‹์ฒ˜๋Ÿผ ์…€์„ ์ง์ ‘ ๋“œ๋ž˜๊ทธ ํ•ด์„œ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ์ฐพ์•„ ๋ด„
  • Reference

2. subItem reoder ํ•˜๊ธฐ

  • ์ด์Šˆ
    • iOS14์— NSDiffableDataSourceSectionSnapshot ๊ฐ€ ๋“ฑ์žฅํ–ˆ๋‹ค. ๋•๋ถ„์— subItem์„ ์†์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜๊ฐ€ ์žˆ๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ... ์ด๊ฑธ reorder ํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?

      • ๋ฌผ๋ก  Diffable์€ ๋„ˆ๋ฌด Hotํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ณ„๋‹ค๋ฅธ ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์ฃผ์ง€ ์•Š์•„๋„ ์ž˜ ๋™์ž‘ํ•˜๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ๋ณด์ธ๋‹ค.
      • ํ•˜์ง€๋งŒ ๋ฌธ์ œ๋Š” ์ด๋ ‡๋‹ค. ์™„์„ฑํ•  ์ˆ˜ ์žˆ๊ฒ ์ง€? ์…€์˜ subItem์ด ๋ฐ–์œผ๋กœ ๋‚˜์™”์œผ๋ฉด ์™„์„ฑํ•  ์ˆ˜ ์žˆ๊ฒ ์ง€? ์— ์žˆ๋˜ ์„œ๋ธŒ์•„์ดํ…œ์ด ์‚ฌ๋ผ์ ธ์•ผ ํ•˜๋Š”๋ฐ ๊ทธ๋ ‡๊ฒŒ ๋˜์ง€ ์•Š๋Š”๋‹ค...
      • ๋ณด์ด๊ธฐ์—๋Š” ์™„์„ฑํ•  ์ˆ˜ ์žˆ๊ฒ ์ง€? ๋ฐ‘์— cell๋“ค์ด ๋“ค์–ด๊ฐ€ ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด์ง€๋งŒ diffable์€ ํ˜„์žฌ ๋ณด์ด๋Š” ์…€๋“ค์„ ๋ชจ๋‘ ํŽผ์ณ์„œ 1์ฐจ์› ๋ฐฐ์—ด๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ๋”ฐ๋ผ์„œ ๋‹จ์ˆœํžˆ hehehe2 ์…€์„ ์ด๋™์‹œํ‚ค๋ฉด ์ด ์…€์˜ parent๊ฐ€ ๋˜๋Š” ์™„์„ฑํ•  ์ˆ˜ ์žˆ๊ฒ ์ง€? ์…€์€ ๋ณ€ํ™”๊ฐ€ ์—†๋‹ค๊ณ  ํŒ๋‹จํ•˜๋Š”์ง€ ์ œ๊ฑฐ๋˜์ง€ ์•Š๋Š”๋‹ค ใ… 

CollectionViewListCell Customizing

  • ์ด์Šˆ

    • CollectionViewListCell ์„ ์‚ฌ์šฉํ•  ๋•Œ cell ์ด ์•„๋‹ˆ๋ผ, ์…€ ์•ˆ์˜ ์ฒดํฌ๋ฒ„ํŠผ ์ด ํด๋ฆญ ๋์„ ๋•Œ๋ฅผ ๊ฐ์ง€ํ•˜๊ณ  ์‹ถ๋‹ค.
  • ๊ฒฐ๋ก 

    • ๊ธฐ๋ณธ defaultContentConfigure๋ฅผ ์‚ฌ์šฉํ•ด์„œ๋Š” ์…€ ์•ˆ์˜ image๊ฐ€ ์„ ํƒ๋์„ ๋•Œ๋ฅผ ๊ฐ์ง€ํ•  ์ˆ˜ ์žˆ๋Š” ์ด๋ฒคํŠธ๋Š” ๋”ฐ๋กœ ์—†๋Š” ๊ฒƒ์œผ๋กœ ํ™•์ธ๋จ

      โ†’ ๋”ฐ๋ผ์„œ custom ํ•„์š”

    • ์šฐ์„  Custom ๊นŒ์ง€๋Š” ํ•ด์„œ ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋Š” ์–ป์—ˆ์œผ๋‚˜ contentView์˜ layout์„ ์žก๋Š” ๊ณผ์ •์—์„œ warning์€ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•จ ใ… ใ… 

      • ContentView์˜ width๋Š” 22์ธ๋ฐ ๋ฒ„ํŠผ์ด 30์ด๋ผ ์ œ๋Œ€๋กœ ์žก์„ ์ˆ˜๊ฐ€ ์—†๋‹ค๋Š” ์›Œ๋‹์œผ๋กœ ๋ณด์ธ๋‹ค...
      • contentView์˜ ๋ ˆ์ด์•„์›ƒ์€ CollectionViewListCell์—์„œ ์žก์•„์ฃผ๋Š” ๊ฒƒ ๊ฐ™์€๋ฐ ์–ด์ฐŒ ํ•  ๋ฐฉ๋ฒ•์„ ๋ชจ๋ฅด๊ฒ ๋‹ค. ๋ณด์—ฌ์ง€๋Š” ๋ ˆ์ด์•„์›ƒ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์–ด๋ณด๊ธด ํ•˜๋Š”๋ฐ.. ๋‚˜์ค‘์— ์ˆ˜์ •ํ•ด๋ณด๋Š”๊ฑธ๋กœ...๐Ÿ˜ฅ
  • ํ•ด๊ฒฐ๊ณผ์ •

    • UIContentConfiguration ๋ฅผ ์ปค์Šคํ…€ ํ•˜๋ ค๋ฉด 2๊ฐ€์ง€๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

      1. UIContentConfiguration๋ฅผ ์ƒ์†๋ฐ›์€ CustomContentConfiguration

        • 2๊ฐ€์ง€ ๋ฉ”์†Œ๋“œ๋ฅผ ํ•„์ˆ˜๋กœ ๊ตฌํ˜„ํ•ด์ค˜์•ผ ํ•œ๋‹ค.
        // ๋ฐ‘์— ํ•„์ˆ˜๋กœ ๊ตฌํ˜„ํ•ด์ค„ CustomContentView๋ฅผ return ํ•ด์ค€๋‹ค.
        func makeContentView() -> UIView & UIContentView 
        
        // ListCell์˜ updateConfiguration(using state:)์—์„œ state๋ฅผ ์ „๋‹ฌ๋ฐ›์•„
        // ์ž๊ธฐ ์ž์‹ ์„ ์„ธํŒ…ํ•œ๋‹ค. 
        func updated(for state: UIConfigurationState) -> Self
      2. ContentConfiguration์˜ ๋ทฐ๊ฐ€ ๋˜์–ด์ค„ UIView & UIContentView๋ฅผ ์ƒ์†๋ฐ›์€ CustomContentView

        • configuration์„ ์ „๋‹ฌ๋ฐ›์•„ ๋ทฐ๋ฅผ ์„ธํŒ…ํ•˜๊ณ  ๋ทฐ์˜ ๋ ˆ์ด์•„์›ƒ์„ ์žก๋Š”๋‹ค.
        init(configuration: TaskContentConfiguration) {
            super.init(frame: .zero)
            setupViews()
            apply(configuration: configuration)
        }
    • PS

      • ๋‹ค์‹œ๋ณด๋‹ˆ Modern collectionView ์˜ˆ์ œ์— Custom Cell ํ•˜๋Š” ์˜ˆ์ œ๋„ ์žˆ๋‹ค...
      • ์ด๊ฑด configuration์„ customํ•˜์ง€ ์•Š๊ณ  default๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์—ฌ๊ธฐ์˜ contentView์— ์ง์ ‘ ๋ทฐ๋ฅผ ๋ถ™์—ฌ์„œ ์ž‘์—…ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ณด์ธ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ ˆ์ด์•„์›ƒ ์›Œ๋‹ ์—†์ด ํ•  ์ˆ˜ ์žˆ์œผ๋ ค๋‚˜... ๋‚˜์ค‘์— ๋” ์ฐธ๊ณ ํ•ด์„œ ๊ฐœ์„ ํ•ด๋ณด๊ธฐ...

Reference

Nov 24, 2020

Xcode ๋นŒ๋“œ๊ฐ€ ๋˜์ง€ ์•Š์„ ๋•Œ

cmd+R ์ด ๋จนํžˆ์ง€ ์•Š๊ณ , xcode์—์„œ ์‹คํ–‰ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด success๋Š” ๋œจ์ง€๋งŒ ์•„๋ฌด๋Ÿฐ ๋ฐ˜์‘๋„ ์ผ์–ด๋‚˜์ง€ ์•Š๋Š”๋‹ค.

project.pbxproj ํŒŒ์ผ์—์„œ ์•ฑ ๊ด€๋ จ reference๊ฐ€ ์ง€์›Œ์ ธ์„œ ์ƒ๊ธด ๋ฌธ์ œ์˜€๋‹ค.

ํ”„๋กœ์ ํŠธ ํŒŒ์ผ์—์„œ ์•„๋ž˜ PBXFileReference section ์ฃผ์„ ๋ฐ‘์— ๋‹ค์Œ ํ”„๋กœ์ ํŠธ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ์ถ”๊ฐ€์‹œ์ผœ์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค.

/* Begin PBXFileReference section */
4C3F5657256B80B4006D7C9F /* HalgoraeDO.app */ = { isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HalgoraeDO.app; sourceTree = BUILT_PRODUCTS_DIR; };

๋ฐ์ดํ„ฐ ๋™๊ธฐํ™”

Reference

๐Ÿ› stackoverflow

UIBezierPath on collectionview

cell ๋‚ด๋ถ€์— collectionview๋ฅผ???

alpha = 0 ์ผ๋•Œ button action

textview autoheight

  • ๋“œ๋ž˜๊ทธ์•ค๋“œ๋ž ์ขŒํ‘œ์— ๋”ฐ๋ฅธ ๋ผ์ธ ์ƒ์„ฑ ์˜ˆ์ œ
Clone this wiki locally