{"id":473907,"date":"2025-09-04T09:01:28","date_gmt":"2025-09-04T09:01:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=473907"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=473907","title":{"rendered":"<span>\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController \u0432 2025 \u0433\u043e\u0434\u0443: \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0438 \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u043e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 2022 \u0433\u043e\u0434\u0443 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/articles\/654517\/\" rel=\"noopener noreferrer nofollow\">\u00ab\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController\u00bb<\/a>, \u0433\u0434\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u0421 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0440\u0451\u0445 \u043b\u0435\u0442, \u0438 \u0432 iOS \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u0442\u0430\u0440\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u0443\u0436\u0435 \u043d\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439.<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 <\/strong>  (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, viewDidUnload \u0438\u043b\u0438 didReceiveMemoryWarning). \u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 API, \u0432\u0442\u043e\u0440\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e UIViewController, \u043d\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 iOS \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u0445\u0443\u043a\u0438<\/strong> (viewIsAppearing, viewSafeAreaInsetsDidChange, viewLayoutMarginsDidChange).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 <strong>Scene lifecycle<\/strong> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u043e\u043a\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Auto Layout \u0442\u043e\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443 UIViewController \u043d\u0430 2025 \u0433\u043e\u0434.<\/p>\n<blockquote>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0433\u043b\u0443\u0431\u0436\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 iOS-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0443 \u0441\u0435\u0431\u044f \u0432 Telegram: <a href=\"https:\/\/t.me\/swiftynew\" rel=\"noopener noreferrer nofollow\">@swiftynew.<\/a><\/p>\n<\/blockquote>\n<h3>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<ol>\n<li>\n<p>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>Layout cycle<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>Child View Controllers<\/p>\n<\/li>\n<li>\n<p>State Restoration \u0438 \u043f\u0430\u043c\u044f\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 + \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430)<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<\/ol>\n<h3>1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController \u2014 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u0430 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0411\u0435\u0437 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u044d\u043a\u0440\u0430\u043d\u044b \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0415\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0440\u043e\u0434\u0435 viewDidUnload() \u0438 didReceiveMemoryWarning(). \u0421\u0435\u0433\u043e\u0434\u043d\u044f viewDidUnload \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 API, \u0430 didReceiveMemoryWarning \u0445\u043e\u0442\u044c \u0438 \u043e\u0441\u0442\u0430\u043b\u0441\u044f, \u043d\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 iOS \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e \u0438 \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439 \u0440\u043e\u043b\u0438 \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u044c\u044e.<\/p>\n<p>\u0417\u0430\u0442\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>viewIsAppearing(_:) \u2014 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 viewWillAppear.<\/p>\n<\/li>\n<li>\n<p>viewSafeAreaInsetsDidChange() \u0438 viewLayoutMarginsDidChange() \u2014 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 <strong>SceneDelegate<\/strong> \u0438 multiwindow \u043d\u0430 iPad.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0432\u0441\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 UIViewController, \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0432\u044b\u0434\u0435\u043b\u044e <strong>\u0447\u0442\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u043e, \u0430 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0433\u043e\u0434\u043d\u044f<\/strong>.<\/p>\n<h3>\u00a02.\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430<\/h3>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0446\u0438\u043a\u043b \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0438\u043c:<\/p>\n<ol>\n<li>\n<p><strong>init(nibName:bundle:) \/ init?(coder:)<\/strong> \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>loadView()<\/strong> \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u0430\u044f view (\u0435\u0441\u043b\u0438 \u0431\u0435\u0437 Storyboard\/XIB).<\/p>\n<\/li>\n<li>\n<p><strong>viewDidLoad()<\/strong> \u2014 view \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f UI \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>updateViewConstraints()<\/strong> \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b (\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e).<\/p>\n<\/li>\n<li>\n<p><strong>viewWillLayoutSubviews()<\/strong> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u043e\u0439 \u0441\u0430\u0431\u0432\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>viewDidLayoutSubviews()<\/strong> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0438 \u0441\u0430\u0431\u0432\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>viewWillAppear(_:)<\/strong> \u2014 \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>viewIsAppearing(_:)<\/strong> (\u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 iOS 13) \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>viewDidAppear(_:)<\/strong> \u2014 \u044d\u043a\u0440\u0430\u043d \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043a\u0430\u0437\u0430\u043d.<\/p>\n<\/li>\n<li>\n<p><strong>viewWillDisappear(_:)<\/strong> \u2014 \u043f\u0435\u0440\u0435\u0434 \u0441\u043a\u0440\u044b\u0442\u0438\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>viewDidDisappear(_:)<\/strong> \u2014 \u044d\u043a\u0440\u0430\u043d \u0443\u0448\u0451\u043b \u0441 \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>didReceiveMemoryWarning() <\/strong>\u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438; \u0432 iOS 13+ \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e API.<\/p>\n<\/li>\n<li>\n<p><strong>deinit<\/strong> \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d.<\/p>\n<\/li>\n<\/ol>\n<h3>3. Layout cycle<\/h3>\n<p>Layout cycle \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0441\u0430\u0431\u0432\u044c\u044e \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c <strong>\u043a\u043e\u0433\u0434\u0430 \u0438 \u0433\u0434\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b \u0438\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u044b<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u0430\u0433\u043e\u0432 \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/h4>\n<ol>\n<li>\n<p><strong>updateViewConstraints()<\/strong><\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f <em>\u043f\u0430\u043a\u0435\u0442\u043d\u043e\u0433\u043e<\/em> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f constraints;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c setNeedsUpdateConstraints(), \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u0438 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0441\u0430\u043c\u0438 constraints \u0432 viewDidLayoutSubviews.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>viewWillLayoutSubviews()<\/strong><\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0430\u0447\u043d\u0451\u0442 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u0431\u0432\u044c\u044e;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0432\u0435\u0440\u0441\u0442\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f).<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>viewDidLayoutSubviews()<\/strong><\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0430\u0431\u0432\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u043d\u043a\u0438 UI, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 CAShapeLayer \u043f\u043e\u0434 \u0440\u0430\u0437\u043c\u0435\u0440\u044b view;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0441\u0447\u0451\u0442 contentInset \u0443 UIScrollView.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<pre><code class=\"swift\">final class ProfileViewController: UIViewController {     private let avatarView = UIImageView(image: UIImage(named: \"avatar\"))      override func viewDidLoad() {         super.viewDidLoad()         view.addSubview(avatarView)         avatarView.translatesAutoresizingMaskIntoConstraints = false         NSLayoutConstraint.activate([             \/\/ \u0417\u0430\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b         ])     }      override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews()         \/\/ \u041a\u0440\u0443\u0433\u043b\u0430\u044f \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a view \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b         avatarView.layer.cornerRadius = avatarView.bounds.width \/ 2         avatarView.layer.clipsToBounds = true     } }<\/code><\/pre>\n<h4> Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0439 \u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0439 constraints \u0432 viewDidLoad (\u0438\u043b\u0438 loadView), \u0430 \u043d\u0435 \u0432 viewDidLayoutSubviews.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f constraints \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 setNeedsUpdateConstraints() \u2192 updateViewConstraints().<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 constraints \u043c\u0435\u043d\u044f\u0439 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 layoutIfNeeded() \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 UIView.animate.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 view \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0439 frame-\u0441\u0430\u0431\u0432\u044c\u044e \u0432 layoutSubviews().<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u0430\u0436\u043d\u043e: <strong>\u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0439 \u043d\u043e\u0432\u044b\u0435 constraints \u0432 viewDidLayoutSubviews<\/strong>, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c layout pass, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u0430\u0440\u043d\u0438\u043d\u0433\u0430\u043c \u0438 \u043f\u0440\u043e\u0441\u0430\u0434\u043a\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/blockquote>\n<h3>4. \u041c\u0435\u0442\u043e\u0434\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 iOS-\u0444\u0438\u0447\u0438 (iPad multitasking, dark mode, Dynamic Type) \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0443\u043c\u0435\u0442\u044c <strong>\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 UIViewController \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<h4>traitCollectionDidChange(_:)<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f <em>traits<\/em> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<ul>\n<li>\n<p>size class (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 split view \u043d\u0430 iPad),<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u043c\u043d\u0430\u044f\/\u0441\u0432\u0435\u0442\u043b\u0430\u044f \u0442\u0435\u043c\u0430,<\/p>\n<\/li>\n<li>\n<p>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0440\u0438\u0444\u0442 (Dynamic Type).<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"swift\">override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {     super.traitCollectionDidChange(previousTraitCollection)      if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {         print(\"\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u044b: \u0441\u0432\u0435\u0442\u043b\u0430\u044f \u2194 \u0442\u0451\u043c\u043d\u0430\u044f\")     } }<\/code><\/pre>\n<h4>viewWillTransition(to:with:)<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043b\u0438 Split View \u043d\u0430 iPad).<\/p>\n<pre><code class=\"swift\">override func viewWillTransition(to size: CGSize,                                  with coordinator: UIViewControllerTransitionCoordinator) {     super.viewWillTransition(to: size, with: coordinator)     coordinator.animate(alongsideTransition: { _ in         print(\"\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e: \\(size)\")     }) }<\/code><\/pre>\n<h4>viewSafeAreaInsetsDidChange()<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <strong>safe area<\/strong>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0438:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043a\u0430\u0437\u0435\/\u0441\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b,<\/p>\n<\/li>\n<li>\n<p>\u0432\u0445\u043e\u0434\u044f\u0449\u0435\u043c \u0437\u0432\u043e\u043d\u043a\u0435 (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0431\u0430\u043d\u043d\u0435\u0440),<\/p>\n<\/li>\n<li>\n<p>\u0441\u043c\u0435\u043d\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"swift\">override func viewSafeAreaInsetsDidChange() {     super.viewSafeAreaInsetsDidChange()     print(\"Safe area \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c: \\(view.safeAreaInsets)\") }<\/code><\/pre>\n<h4>viewLayoutMarginsDidChange()<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 layoutMargins. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u2014 \u0435\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<pre><code class=\"swift\">override func viewLayoutMarginsDidChange() {     super.viewLayoutMarginsDidChange()     print(\"layoutMargins \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c: \\(view.layoutMargins)\") }<\/code><\/pre>\n<h4>Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>dark mode \/ Dynamic Type<\/strong> \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c traitCollectionDidChange.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>\u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432<\/strong> \u0438 Split View \u2014 viewWillTransition(to:with:).<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>\u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0438 safe area<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c inset \u0443 ScrollView) \u2014 viewSafeAreaInsetsDidChange.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>\u0442\u043e\u043d\u043a\u043e\u0439 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0440\u0441\u0442\u043a\u0438<\/strong> \u2014 viewLayoutMarginsDidChange.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u0445\u0430\u043a\u0430 \u0432 viewDidLayoutSubviews().<\/p>\n<h3>5. Child View Controllers<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430. \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <strong>\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u0431\u0431\u0430\u0440\u043e\u0432, \u043f\u0435\u0439\u0434\u0436\u0435\u0440\u043e\u0432, \u0438\u043b\u0438 split-layout \u044d\u043a\u0440\u0430\u043d\u043e\u0432).<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 VC \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430, \u0432\u0430\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<h4>addChild(_:)<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<pre><code class=\"swift\">addChild(child)                      \/\/ 1. \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c UIKit, \u0447\u0442\u043e child \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f view.addSubview(child.view)          \/\/ 2. \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e view \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \/\/ ... (\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b) child.didMove(toParent: self)        \/\/ 3. \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u043c, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/code><\/pre>\n<blockquote>\n<p>\u26a0\ufe0f didMove(toParent:) \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 <strong>\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438<\/strong> \u2014 \u044d\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<\/blockquote>\n<h4>removeFromParent()<\/h4>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<pre><code class=\"swift\">child.willMove(toParent: nil)        \/\/ 1. \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u043c \u043e \u0432\u044b\u0445\u043e\u0434\u0435 child.view.removeFromSuperview()     \/\/ 2. \u0443\u0431\u0438\u0440\u0430\u0435\u043c view child.removeFromParent()   <\/code><\/pre>\n<blockquote>\n<p>\u041f\u0440\u0438 removeFromParent() UIKit \u0441\u0430\u043c \u0432\u044b\u0437\u043e\u0432\u0435\u0442 didMove(toParent: nil).<\/p>\n<\/blockquote>\n<h4>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 <strong>\u0441\u0430\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 children \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 TabBarController), UIKit \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0430\u043c \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f viewWillAppear \/ viewDidAppear.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>beginAppearanceTransition(_:animated:)<\/p>\n<\/li>\n<li>\n<p>endAppearanceTransition()<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e child VC.<\/p>\n<h4>Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705 \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435: addChild \u2192 addSubview (+ \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b) \u2192 didMove(toParent:).<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435: willMove(toParent:nil) \u2192 removeFromSuperview \u2192 removeFromParent().<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 (\u043f\u0435\u0439\u0434\u0436\u0435\u0440\/\u0442\u0430\u0431\u0430\u0440) \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c lifecycle \u0434\u0435\u0442\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 beginAppearanceTransition \/ endAppearanceTransition.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c child.view \u043a\u0430\u043a \u0441\u0430\u0431\u0432\u044c\u044e \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u2192 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 VC <strong>\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c<\/strong> lifecycle \u0441\u043e\u0431\u044b\u0442\u0438\u044f!<\/p>\n<\/blockquote>\n<h3>\u00a06. State Restoration \u0438 \u043f\u0430\u043c\u044f\u0442\u044c<\/h3>\n<p>iOS \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 UIViewController \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <strong>state restoration<\/strong>. \u0410 \u0435\u0449\u0451 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h4>\n<ul>\n<li>\n<p><strong>encodeRestorableState(with:)<\/strong><\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0442\u0430\u0431, \u043e\u0442\u043a\u0440\u044b\u0442\u0430\u044f \u0432\u043a\u043b\u0430\u0434\u043a\u0430).<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>decodeRestorableState(with:)<\/strong><\/p>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437 \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>applicationFinishedRestoringState()<\/strong><\/p>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>didReceiveMemoryWarning()<\/strong><\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 (iOS &lt; 13) \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0430 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u043a\u044d\u0448 \u0438\u043b\u0438 \u043e\u0431\u043d\u0443\u043b\u044f\u0442\u044c view. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 iOS 11\u201313 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c\u044e: \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 iOS \u0447\u0430\u0449\u0435 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0438\u043b\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0441\u0441\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0442\u044c memory warning. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0435\u0433\u043e \u043f\u0443\u0441\u0442\u044b\u043c \u0438\u043b\u0438 \u0432\u043e\u0432\u0441\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442.<\/p>\n<\/li>\n<\/ul>\n<h4>Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705 \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 state restoration \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u00ab\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f\u00bb \u0432 \u0442\u043e \u0436\u0435 \u043c\u0435\u0441\u0442\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Safari).<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (UserDefaults, CoreData), \u0430 \u043d\u0435 state restoration.<\/p>\n<\/li>\n<li>\n<p>\u2705 didReceiveMemoryWarning() \u043c\u043e\u0436\u043d\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u2014 \u0432 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 iOS \u043e\u043d \u043d\u0435 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 2025 \u0433\u043e\u0434\u0443 \u043c\u0435\u0442\u043e\u0434\u044b <em>encodeRestorableState(with:)<\/em>, <em>decodeRestorableState(with:)<\/em> \u0438 <em>applicationFinishedRestoringState() <\/em>\u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e API \u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f state restoration (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0441 multiwindow \u043d\u0430 iPad \u0438\u043b\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0432\u0440\u043e\u0434\u0435 Pages \u0438\u043b\u0438 Safari). \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 state restoration, \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044f \u044f\u0432\u043d\u043e\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 UserDefaults, CoreData, NSUserActivity \u0438\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b.<\/p>\n<h3>7. \u0423\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<ul>\n<li>\n<p>viewDidUnload()   &#8212;  \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0434\u0430\u043b\u0451\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 iOS 6.    \u0420\u0430\u043d\u044c\u0448\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 view \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u043b\u0430\u0441\u044c \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<\/li>\n<li>\n<p>willRotate(to:duration:), didRotate(from:) \u2014 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430(&lt; iOS 8), \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 viewWillTransition(to:with:).<\/p>\n<\/li>\n<li>\n<p>didReceiveMemoryWarning() &#8212; \u043d\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u043a\u0430\u043a deprecated, \u043d\u043e \u0432 iOS 13+ \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0420\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0441\u044f \u0434\u043b\u044f \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430\/\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.    \u0421\u0435\u0433\u043e\u0434\u043d\u044f iOS \u0441\u0430\u043c\u0430 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 view \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0442\u0430\u0440\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 (&lt; iOS 12).<\/p>\n<\/li>\n<\/ul>\n<h3>8. \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/h3>\n<h4>loadViewIfNeeded()<\/h4>\n<ul>\n<li>\n<p>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 view, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c UI \u0437\u0430\u0440\u0430\u043d\u0435\u0435, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043d\u0430\u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a view.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 view \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430 \u2192 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 loadView() \u2192 \u043f\u043e\u0442\u043e\u043c viewDidLoad()<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 view \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430 \u2192 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0451 (\u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442).<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"swift\">func attach(_ child: UIViewController) {     addChild(child)     child.loadViewIfNeeded() \/\/ \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0430\u0443\u0442\u043b\u0435\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u044b     \/\/ \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c API\/\u0441\u0430\u0431\u0432\u044c\u044e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e     view.addSubview(child.view)     child.view.translatesAutoresizingMaskIntoConstraints = false     NSLayoutConstraint.activate([           \/\/\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b...     ])     child.didMove(toParent: self) }<\/code><\/pre>\n<h4>systemLayoutSizeFitting(_:)<\/h4>\n<ul>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 <strong>\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 view<\/strong> \u0441 \u0443\u0447\u0451\u0442\u043e\u043c Auto Layout.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f self-sizing \u044f\u0447\u0435\u0435\u043a \u0432 UITableView \/ UICollectionView.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"swift\">let targetSize = CGSize(width: view.bounds.width, height: UIView.layoutFittingCompressedSize.height) let fittingSize = customView.systemLayoutSizeFitting(targetSize) print(\"\u0412\u044b\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430: \\(fittingSize.height)\")<\/code><\/pre>\n<h4>sizeThatFits(_:)<\/h4>\n<ul>\n<li>\n<p>\u041f\u043e\u0445\u043e\u0436 \u043d\u0430 systemLayoutSizeFitting, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 Auto Layout.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0432\u044c\u044e\u0448\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<\/li>\n<\/ul>\n<h4>intrinsicContentSize<\/h4>\n<ul>\n<li>\n<p>\u00ab\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439\u00bb \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044c\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, UILabel \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h4>invalidateIntrinsicContentSize()<\/h4>\n<ul>\n<li>\n<p>\u0421\u043e\u043e\u0431\u0449\u0430\u0435\u0442 Auto Layout, \u0447\u0442\u043e intrinsicContentSize \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440: \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430, \u0433\u0434\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0442\u0435\u043a\u0441\u0442 \u2192 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440.<\/p>\n<\/li>\n<\/ul>\n<h4>UILayoutGuide<\/h4>\n<ul>\n<li>\n<p>\u041b\u0451\u0433\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0442\u043a\u0438, <strong>\u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 view<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u00ab\u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0430\u044f \u043f\u0440\u043e\u043a\u043b\u0430\u0434\u043a\u0430\u00bb \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h3>9.\u0421\u0445\u0435\u043c\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 UIViewController<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p><strong>\u041c\u0435\u0442\u043e\u0434<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">init(nibName:bundle:) \/ init?(coder:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 VC<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, DI<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">loadView()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a view<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 view (\u0435\u0441\u043b\u0438 \u0431\u0435\u0437 XIB\/Storyboard)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewDidLoad()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 view (1 \u0440\u0430\u0437)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 UI, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0430\u0431\u0432\u044c\u044e, \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewWillAppear(_:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u043e\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041b\u0451\u0433\u043a\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f UI<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewIsAppearing(_:) <\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0434\u0451\u0436\u043d\u0435\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a\/\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">updateViewConstraints()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0430\u043a\u0435\u0442\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 constraints<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewWillLayoutSubviews()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0435\u0440\u0435\u0434 layout<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u0447\u0451\u0442\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewDidLayoutSubviews()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0441\u043b\u0435 layout<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0434\u0433\u043e\u043d\u043a\u0430 UI \u043f\u043e\u0434 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewDidAppear(_:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0430\u0440\u0442 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439, \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewWillDisappear(_:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0435\u0440\u0435\u0434 \u0441\u043a\u0440\u044b\u0442\u0438\u0435\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043e\u0442\u043c\u0435\u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewDidDisappear(_:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0441\u043b\u0435 \u0441\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">traitCollectionDidChange(_:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 size class \/ dark mode<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f UI<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewWillTransition(to:with:)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0435\u0430\u043a\u0446\u0438\u044f \u043d\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442, split view<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewSafeAreaInsetsDidChange()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 safe area<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 inset-\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">viewLayoutMarginsDidChange()<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 layoutMargins<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043d\u043a\u0430\u044f \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f UI<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">beginAppearanceTransition \/ endAppearanceTransition<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u0445<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f lifecycle child<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">didReceiveMemoryWarning() <\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 iOS&lt;12<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">deinit<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0438 VC<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043e\u0442\u043f\u0438\u0441\u043a\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ec0\/8b7\/5f8\/ec08b75f8858d6008e2960ba94bccc33.png\" alt=\"\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController\" title=\"\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController\" width=\"872\" height=\"882\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ec0\/8b7\/5f8\/ec08b75f8858d6008e2960ba94bccc33.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ec0\/8b7\/5f8\/ec08b75f8858d6008e2960ba94bccc33.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController<\/figcaption><\/div>\n<\/figure>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController \u2014 \u0431\u0430\u0437\u0430 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<ul>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 viewDidUnload \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438 \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 API. \u0410 didReceiveMemoryWarning \u0445\u043e\u0442\u044c \u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440, \u0432 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0445\u0443\u043a\u0438: viewIsAppearing, viewSafeAreaInsetsDidChange, viewLayoutMarginsDidChange.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0442\u043a\u0438 \u0432\u0430\u0436\u043d\u044b updateViewConstraints, intrinsicContentSize \u0438 UILayoutGuide.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/943778\/\"> https:\/\/habr.com\/ru\/articles\/943778\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 2022 \u0433\u043e\u0434\u0443 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/articles\/654517\/\" rel=\"noopener noreferrer nofollow\">\u00ab\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController\u00bb<\/a>, \u0433\u0434\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u0421 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0440\u0451\u0445 \u043b\u0435\u0442, \u0438 \u0432 iOS \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u0442\u0430\u0440\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u0443\u0436\u0435 \u043d\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439.<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 <\/strong>  (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, viewDidUnload \u0438\u043b\u0438 didReceiveMemoryWarning). \u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 API, \u0432\u0442\u043e\u0440\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e UIViewController, \u043d\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 iOS \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u0445\u0443\u043a\u0438<\/strong> (viewIsAppearing, viewSafeAreaInsetsDidChange, viewLayoutMarginsDidChange).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 <strong>Scene lifecycle<\/strong> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u043e\u043a\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Auto Layout \u0442\u043e\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443 UIViewController \u043d\u0430 2025 \u0433\u043e\u0434.<\/p>\n<blockquote>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0433\u043b\u0443\u0431\u0436\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 iOS-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0443 \u0441\u0435\u0431\u044f \u0432 Telegram: <a href=\"https:\/\/t.me\/swiftynew\" rel=\"noopener noreferrer nofollow\">@swiftynew.<\/a><\/p>\n<\/blockquote>\n<h3>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<ol>\n<li>\n<p>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>Layout cycle<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>Child View Controllers<\/p>\n<\/li>\n<li>\n<p>State Restoration \u0438 \u043f\u0430\u043c\u044f\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 + \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430)<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<\/ol>\n<h3>1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0416\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b UIViewController \u2014 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u0430 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0411\u0435\u0437 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u044d\u043a\u0440\u0430\u043d\u044b \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0415\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0440\u043e\u0434\u0435 viewDidUnload() \u0438 didReceiveMemoryWarning(). \u0421\u0435\u0433\u043e\u0434\u043d\u044f viewDidUnload \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 API, \u0430 didReceiveMemoryWarning \u0445\u043e\u0442\u044c \u0438 \u043e\u0441\u0442\u0430\u043b\u0441\u044f, \u043d\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 iOS \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e \u0438 \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439 \u0440\u043e\u043b\u0438 \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u044c\u044e.<\/p>\n<p>\u0417\u0430\u0442\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>viewIsAppearing(_:) \u2014 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 viewWillAppear.<\/p>\n<\/li>\n<li>\n<p>viewSafeAreaInsetsDidChange() \u0438 viewLayoutMarginsDidChange() \u2014 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 <strong>SceneDelegate<\/strong> \u0438 multiwindow \u043d\u0430 iPad.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0432\u0441\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 UIViewController, \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0432\u044b\u0434\u0435\u043b\u044e <strong>\u0447\u0442\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u043e, \u0430 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0433\u043e\u0434\u043d\u044f<\/strong>.<\/p>\n<h3>\u00a02.\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430<\/h3>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0446\u0438\u043a\u043b \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0438\u043c:<\/p>\n<ol>\n<li>\n<p><strong>init(nibName:bundle:) \/ init?(coder:)<\/strong> \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>loadView()<\/strong> \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u0430\u044f view (\u0435\u0441\u043b\u0438 \u0431\u0435\u0437 Storyboard\/XIB).<\/p>\n<\/li>\n<li>\n<p><strong>viewDidLoad()<\/strong> \u2014 view \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f UI \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>updateViewConstraints()<\/strong> \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b (\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e).<\/p>\n<\/li>\n<li>\n<p><strong>viewWillLayoutSubviews()<\/strong> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u043e\u0439 \u0441\u0430\u0431\u0432\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>viewDidLayoutSubviews()<\/strong> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0438 \u0441\u0430\u0431\u0432\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>viewWillAppear(_:)<\/strong> \u2014 \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>viewIsAppearing(_:)<\/strong> (\u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 iOS 13) \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>viewDidAppear(_:)<\/strong> \u2014 \u044d\u043a\u0440\u0430\u043d \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043a\u0430\u0437\u0430\u043d.<\/p>\n<\/li>\n<li>\n<p><strong>viewWillDisappear(_:)<\/strong> \u2014 \u043f\u0435\u0440\u0435\u0434 \u0441\u043a\u0440\u044b\u0442\u0438\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>viewDidDisappear(_:)<\/strong> \u2014 \u044d\u043a\u0440\u0430\u043d \u0443\u0448\u0451\u043b \u0441 \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>didReceiveMemoryWarning() <\/strong>\u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438; \u0432 iOS 13+ \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e API.<\/p>\n<\/li>\n<li>\n<p><strong>deinit<\/strong> \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d.<\/p>\n<\/li>\n<\/ol>\n<h3>3. Layout cycle<\/h3>\n<p>Layout cycle \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0441\u0430\u0431\u0432\u044c\u044e \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c <strong>\u043a\u043e\u0433\u0434\u0430 \u0438 \u0433\u0434\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b \u0438\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u044b<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u0430\u0433\u043e\u0432 \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/h4>\n<ol>\n<li>\n<p><strong>updateViewConstraints()<\/strong><\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f <em>\u043f\u0430\u043a\u0435\u0442\u043d\u043e\u0433\u043e<\/em> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f constraints;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c setNeedsUpdateConstraints(), \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u0438 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0441\u0430\u043c\u0438 constraints \u0432 viewDidLayoutSubviews.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>viewWillLayoutSubviews()<\/strong><\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0430\u0447\u043d\u0451\u0442 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u0431\u0432\u044c\u044e;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0432\u0435\u0440\u0441\u0442\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f).<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>viewDidLayoutSubviews()<\/strong><\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0430\u0431\u0432\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u043d\u043a\u0438 UI, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 CAShapeLayer \u043f\u043e\u0434 \u0440\u0430\u0437\u043c\u0435\u0440\u044b view;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0441\u0447\u0451\u0442 contentInset \u0443 UIScrollView.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<pre><code class=\"swift\">final class ProfileViewController: UIViewController {     private let avatarView = UIImageView(image: UIImage(named: \"avatar\"))      override func viewDidLoad() {         super.viewDidLoad()         view.addSubview(avatarView)         avatarView.translatesAutoresizingMaskIntoConstraints = false         NSLayoutConstraint.activate([             \/\/ \u0417\u0430\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b         ])     }      override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews()         \/\/ \u041a\u0440\u0443\u0433\u043b\u0430\u044f \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a view \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b         avatarView.layer.cornerRadius = avatarView.bounds.width \/ 2         avatarView.layer.clipsToBounds = true     } }<\/code><\/pre>\n<h4> Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0439 \u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0439 constraints \u0432 viewDidLoad (\u0438\u043b\u0438 loadView), \u0430 \u043d\u0435 \u0432 viewDidLayoutSubviews.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f constraints \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 setNeedsUpdateConstraints() \u2192 updateViewConstraints().<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 constraints \u043c\u0435\u043d\u044f\u0439 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0439 layoutIfNeeded() \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 UIView.animate.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 view \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0439 frame-\u0441\u0430\u0431\u0432\u044c\u044e \u0432 layoutSubviews().<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u0430\u0436\u043d\u043e: <strong>\u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0439 \u043d\u043e\u0432\u044b\u0435 constraints \u0432 viewDidLayoutSubviews<\/strong>, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c layout pass, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u0430\u0440\u043d\u0438\u043d\u0433\u0430\u043c \u0438 \u043f\u0440\u043e\u0441\u0430\u0434\u043a\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/blockquote>\n<h3>4. \u041c\u0435\u0442\u043e\u0434\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 iOS-\u0444\u0438\u0447\u0438 (iPad multitasking, dark mode, Dynamic Type) \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0443\u043c\u0435\u0442\u044c <strong>\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 UIViewController \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<h4>traitCollectionDidChange(_:)<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f <em>traits<\/em> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<ul>\n<li>\n<p>size class (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 split view \u043d\u0430 iPad),<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u043c\u043d\u0430\u044f\/\u0441\u0432\u0435\u0442\u043b\u0430\u044f \u0442\u0435\u043c\u0430,<\/p>\n<\/li>\n<li>\n<p>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0440\u0438\u0444\u0442 (Dynamic Type).<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"swift\">override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {     super.traitCollectionDidChange(previousTraitCollection)      if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {         print(\"\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u044b: \u0441\u0432\u0435\u0442\u043b\u0430\u044f \u2194 \u0442\u0451\u043c\u043d\u0430\u044f\")     } }<\/code><\/pre>\n<h4>viewWillTransition(to:with:)<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043b\u0438 Split View \u043d\u0430 iPad).<\/p>\n<pre><code class=\"swift\">override func viewWillTransition(to size: CGSize,                                  with coordinator: UIViewControllerTransitionCoordinator) {     super.viewWillTransition(to: size, with: coordinator)     coordinator.animate(alongsideTransition: { _ in         print(\"\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e: \\(size)\")     }) }<\/code><\/pre>\n<h4>viewSafeAreaInsetsDidChange()<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <strong>safe area<\/strong>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0438:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043a\u0430\u0437\u0435\/\u0441\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b,<\/p>\n<\/li>\n<li>\n<p>\u0432\u0445\u043e\u0434\u044f\u0449\u0435\u043c \u0437\u0432\u043e\u043d\u043a\u0435 (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0431\u0430\u043d\u043d\u0435\u0440),<\/p>\n<\/li>\n<li>\n<p>\u0441\u043c\u0435\u043d\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"swift\">override func viewSafeAreaInsetsDidChange() {     super.viewSafeAreaInsetsDidChange()     print(\"Safe area \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c: \\(view.safeAreaInsets)\") }<\/code><\/pre>\n<h4>viewLayoutMarginsDidChange()<\/h4>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 layoutMargins. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u2014 \u0435\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<pre><code class=\"swift\">override func viewLayoutMarginsDidChange() {     super.viewLayoutMarginsDidChange()     print(\"layoutMargins \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c: \\(view.layoutMargins)\") }<\/code><\/pre>\n<h4>Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>dark mode \/ Dynamic Type<\/strong> \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c traitCollectionDidChange.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>\u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432<\/strong> \u0438 Split View \u2014 viewWillTransition(to:with:).<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>\u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0438 safe area<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c inset \u0443 ScrollView) \u2014 viewSafeAreaInsetsDidChange.<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f <strong>\u0442\u043e\u043d\u043a\u043e\u0439 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0440\u0441\u0442\u043a\u0438<\/strong> \u2014 viewLayoutMarginsDidChange.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u0445\u0430\u043a\u0430 \u0432 viewDidLayoutSubviews().<\/p>\n<h3>5. Child View Controllers<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430. \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <strong>\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u0431\u0431\u0430\u0440\u043e\u0432, \u043f\u0435\u0439\u0434\u0436\u0435\u0440\u043e\u0432, \u0438\u043b\u0438 split-layout \u044d\u043a\u0440\u0430\u043d\u043e\u0432).<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 VC \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430, \u0432\u0430\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<h4>addChild(_:)<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<pre><code class=\"swift\">addChild(child)                      \/\/ 1. \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c UIKit, \u0447\u0442\u043e child \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f view.addSubview(child.view)          \/\/ 2. \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e view \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \/\/ ... (\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b) child.didMove(toParent: self)        \/\/ 3. \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u043c, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/code><\/pre>\n<blockquote>\n<p>\u26a0\ufe0f didMove(toParent:) \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 <strong>\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438<\/strong> \u2014 \u044d\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<\/blockquote>\n<h4>removeFromParent()<\/h4>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<pre><code class=\"swift\">child.willMove(toParent: nil)        \/\/ 1. \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u043c \u043e \u0432\u044b\u0445\u043e\u0434\u0435 child.view.removeFromSuperview()     \/\/ 2. \u0443\u0431\u0438\u0440\u0430\u0435\u043c view child.removeFromParent()   <\/code><\/pre>\n<blockquote>\n<p>\u041f\u0440\u0438 removeFromParent() UIKit \u0441\u0430\u043c \u0432\u044b\u0437\u043e\u0432\u0435\u0442 didMove(toParent: nil).<\/p>\n<\/blockquote>\n<h4>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 <strong>\u0441\u0430\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 children \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 TabBarController), UIKit \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0430\u043c \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f viewWillAppear \/ viewDidAppear.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>beginAppearanceTransition(_:animated:)<\/p>\n<\/li>\n<li>\n<p>endAppearanceTransition()<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e child VC.<\/p>\n<h4>Best practices<\/h4>\n<ul>\n<li>\n<p>\u2705 \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435: addChild \u2192 addSubview (+ \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442\u044b) \u2192 didMove(toParent:).<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435: willMove(toParent:nil) \u2192 removeFromSuperview \u2192 removeFromParent().<\/p>\n<\/li>\n<li>\n<p>\u2705 \u0414\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 (\u043f\u0435\u0439\u0434\u0436\u0435\u0440\/\u0442\u0430\u0431\u0430\u0440) \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c lifecycle \u0434\u0435\u0442\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 beginAppearanceTransition \/ endAppearanceTransition.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c child.view \u043a\u0430\u043a \u0441\u0430\u0431\u0432\u044c\u044e \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u2192 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 VC <strong>\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c<\/strong> lifecycle \u0441\u043e\u0431\u044b\u0442\u0438\u044f!<\/p>\n<\/blockquote>\n<h3>\u00a06. State Restoration \u0438 \u043f\u0430\u043c\u044f\u0442\u044c<\/h3>\n<p>iOS \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 UIViewController \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <strong>state restoration<\/strong>. \u0410 \u0435\u0449\u0451 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h4>\n<ul>\n<li>\n<p><strong>encodeRestorableState(with:)<\/strong><\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0442\u0430\u0431, \u043e\u0442\u043a\u0440\u044b\u0442\u0430\u044f \u0432\u043a\u043b\u0430\u0434\u043a\u0430).<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>decodeRestorableState(with:)<\/strong><\/p>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437 \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>applicationFinishedRestoringState()<\/strong><\/p>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>didReceiveMemoryWarning()<\/strong><\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 (iOS &lt; 13) \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0430 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u043a\u044d\u0448 \u0438\u043b\u0438 \u043e\u0431\u043d\u0443\u043b\u044f\u0442\u044c view. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 iOS 11\u201313 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c\u044e: \u043f\u0440\u0438 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-473907","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=473907"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473907\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}