๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โ—๏ธError

[Error ํ•ด๊ฒฐ๋ฒ• ํฌํ•จ] NSGenericException,reason:Unable to activate constraint with anchors

by Fomagran ๐Ÿ’ป 2021. 5. 13.
728x90
๋ฐ˜์‘ํ˜•

์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค!

 

์˜ค๋Š˜ ๋งŒ๋‚œ ์—๋Ÿฌ ๋Š” ์ฝ”๋“œ๋กœ ์˜คํ† ๋ ˆ์ด์•„์›ƒ์„ ์žก์„๋•Œ ๋ฐœ์ƒํ–ˆ๋Š”๋ฐ์š”.

 

์•„๋ž˜์™€ ๊ฐ™์ด... ์ปจ์ŠคํŠธ๋ ˆ์ธ์„ ํ™œ์„ฑํ™”์‹œํ‚ฌ ์ˆ˜ ์—†๋‹ค... ๊ทธ๊ฑด ๋ถˆ๋ฒ•์ด๋‹ค... ๋ผ๊ณ  ํ•˜๋Š”๋ฐ

 

 

์ด์œ ๋Š” ๊ฐ„๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค.

 

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ปจ์ŠคํŠธ๋ ˆ์ธ์„ ์„ค์ •ํ•ด์ค€ ๋‹ค์Œ addSubview๋กœ ๋„ฃ์–ด์คฌ๋Š”๋ฐ ๋จผ์ € addSubview๋ฅผ ํ•œ ๋‹ค์Œ ์ปจ์ŠคํŠธ๋ ˆ์ธ์„ ์žก์•„์ค˜์•ผํ–ˆ์Šต๋‹ˆ๋‹ค.

	skView.translatesAutoresizingMaskIntoConstraints = false
        skView.centerXAnchor.constraint(equalTo:view.centerXAnchor)
                  .isActive = true
        skView.centerYAnchor.constraint(equalTo:view.centerYAnchor)
                  .isActive = true
        skView.heightAnchor.constraint(equalToConstant: 200)
                  .isActive = true
        skView.widthAnchor.constraint(equalToConstant: 200)
                  .isActive = true
        
        view.addSubview(skView)

 

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋จผ์ € view๋ฅผ  ์ถ”๊ฐ€ํ•ด์ค€ ๋‹ค์Œ ์˜คํ† ๋ ˆ์ด์•„์›ƒ์„ ์žก์•„์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค!

 

	view.addSubview(skView)
        
        skView.translatesAutoresizingMaskIntoConstraints = false
        skView.centerXAnchor.constraint(equalTo:view.centerXAnchor)
                  .isActive = true
        skView.centerYAnchor.constraint(equalTo:view.centerYAnchor)
                  .isActive = true
        skView.heightAnchor.constraint(equalToConstant: 200)
                  .isActive = true
        skView.widthAnchor.constraint(equalToConstant: 200)
                  .isActive = true
728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€