{"id":269019,"date":"2015-11-25T22:32:03","date_gmt":"2015-11-25T19:32:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=269019"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=269019","title":{"rendered":"\u0414\u0438\u0437\u0430\u0439\u043d\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u044f\u0447\u0435\u0435\u043a \u0432 \u043e\u0434\u043d\u043e\u043c XIB-\u0435 \u0441 UITableView"},"content":{"rendered":"<p>       \u0410 \u0437\u0430\u043e\u0434\u043d\u043e \u0440\u0430\u0437 \u0438 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0447\u0435\u0435\u043a.<\/p>\n<p>  Disclaimer:<br \/>  \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0442\u043e\u0448\u043d\u043e\u0442\u0443 \u0438 \u0434\u044c\u044f\u0432\u043e\u043b\u0430, \u0441\u0442\u0430\u0440\u0438\u043a\u0430\u043c \u0438 \u0431\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0434\u0435\u0442\u044f\u043c \u043f\u0440\u043e\u0441\u044c\u0431\u0430 \u043d\u0435 \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<p>  <s>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/s> \u041f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u2014 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0430\u044f \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430. \u041d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, Xcode \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u0439\u043c\u0443 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043e\u043a, \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0431\u0430\u0433\u043e\u0432. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/956\/d65\/a0f\/956d65a0fb924a0d8b5829927f8eba96.png\"\/><br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 iOS5 \u0432\u0432\u0435\u043b\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0438\u0447\u0443 \u2014 Storyboard, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u044f\u0447\u0435\u0435\u043a \u043f\u0440\u044f\u043c\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 NIB-\u044b). \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0440\u0435\u0448\u0438\u043b\u0438 \u043d\u0435 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 XIB-\u044b. <br \/>  \u041c\u0435\u043d\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0437\u0430\u0434\u0430\u0447\u0438\u043b\u043e, \u0447\u0442\u043e \u0432 \u0441\u0432\u0435\u0436\u0435\u043c Xcode \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c UITableViewController, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0440\u0430\u0437\u0443 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u044f\u0447\u0435\u0439\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 Xcode \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0447\u0442\u043e \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u043b \u043d\u0435\u043b\u044c\u0437\u044f. <\/p>\n<p>  \u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443 <i>\u00ab\u0430 \u0437\u0430\u0447\u0435\u043c\u00bb<\/i>:<br \/>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u0442\u043e\u0440\u0438\u0431\u043e\u0440\u0434\u0430. \u041f\u043e\u0447\u0435\u043c\u0443 \u0434\u0432\u0430? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043f\u0438\u0445\u0430\u0442\u044c \u0433\u043e\u0440\u0443 \u0432\u044c\u044e\u0448\u0435\u043a, \u043a\u043d\u043e\u043f\u043e\u0447\u0435\u043a \u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u0435\u043a \u0432 \u043e\u0434\u0438\u043d, \u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u0438\u0439 \u0438 \u0440\u0435\u0437\u0432\u044b\u0439 (\u043f\u0440\u0430\u0432\u0434\u0430 \u0433\u043e\u0434 \u043d\u0430\u0437\u0430\u0434) MacBook Pro Retina 13&quot; \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u044b\u043a\u0432\u0443.<br \/>  \u0418\u0442\u0430\u043a, \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u0442\u043e\u0440\u0438\u0431\u043e\u0440\u0434\u0430, \u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043e\u0431\u0430 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438 \u0440\u0430\u0437\u043d\u043e\u043c \u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432.<br \/>  \u041f\u044b\u0442\u043b\u0438\u0432\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043c\u0435\u0442\u0438\u0442, \u0447\u0442\u043e \u0432 iOS9 \u0432\u0432\u0435\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 storyboard, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 iOS8, \u0430 \u0442\u043e \u0438 7? \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0431\u044f\u0442\u0430 \u0438\u0437 \u041a\u0443\u043f\u0435\u0440\u0442\u0438\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u043b\u044e\u0431\u044f\u0442.<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c ViewController \u0431\u0435\u0437 View \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 Xib \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c loadView. \u0418\u043b\u0438 \u044f\u0432\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e nibName:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/178\/fa4\/c31\/178fa4c313ae46809fd32b3e40c47f8d.png\"\/><br \/>  \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u044f\u0432\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u043d\u043e \u0432 Xcode 7 \u044f \u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0448\u0435\u043b.<\/p>\n<p>  \u0418 \u0442\u0443\u0442 \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u044f\u0447\u0435\u0435\u043a \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0442\u044c \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0435 Xib-\u044b, \u043f\u0440\u0438\u0447\u0435\u043c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0432 \u0444\u0430\u0439\u043b, \u0438 \u044f\u0432\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u043e\u0434\u0435. \u041f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Storyboard \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  \u0418 \u0432\u043e\u0442 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c (\u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 Objective C, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0447\u043e\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f):<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c .h \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:  <\/p>\n<pre><code class=\"objectivec\">@interface UITableView (XibCells) @property (nonatomic, strong) IBOutletCollection(UITableViewCell) NSArray* cellPrototypes; @end <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043a\u0438\u043d\u0443\u0442\u044c \u0432 \u0444\u0430\u0439\u043b Interface Builder \u044f\u0447\u0435\u0439\u043a\u0438 (\u043f\u0440\u0430\u0432\u0434\u0430 \u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u0440\u044f\u0434\u043e\u043c), \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0445 \u043a IBOutletCollection cellPrototypes<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/39a\/657\/010\/39a6570108bc4a4f96481927dd0cc8cf.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e \u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0438\u0445 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u043b\u0430 \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 .m \u0444\u0430\u0439\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 UINib \u0441 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <i>instantiateWithOwner:options:<\/i>  <\/p>\n<pre><code class=\"objectivec\">@interface PrepopulatedNib: UINib @property (nonatomic, strong) NSData* nibData; @end  @implementation PrepopulatedNib + (instancetype)nibWithObjects:(NSArray*)objects {   PrepopulatedNib* nib = [[self alloc] init];   nib.nibData = [NSKeyedArchiver archivedDataWithRootObject:objects];   return nib; } - (NSArray *)instantiateWithOwner:(id)ownerOrNil options:(NSDictionary *)optionsOrNil {   return [NSKeyedUnarchiver unarchiveObjectWithData:_nibData]; } @end <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 PrepopulatedNib \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 NSData \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e NSKeyedArchiver.<br \/>  \u0414\u0430\u043b\u0435\u0435 UITableView \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 instantiateWithOwner:nil options:nil, \u0438 \u043c\u044b \u0440\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043a\u043e\u043f\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u042f\u0447\u0435\u0439\u043a\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c 100% \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438\u0437 NIB-a \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 NSCoding.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0442\u0440\u0438\u0445: \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 PrepopulatedNib:  <\/p>\n<pre><code class=\"objectivec\">@implementation UITableView (XibCells) - (void)setCellPrototypes:(NSArray*)cellPrototypes {   for (UITableViewCell* cell in cellPrototypes) {       [self registerNib:[PrepopulatedNib nibWithObjects:@[cell]] forCellReuseIdentifier:cell.reuseIdentifier];   } } @end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0438\u0437 Storyboard. \u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u043e\u0440\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u044f\u0447\u0435\u0435\u043a, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u043b\u0438 \u0434\u0430\u0440\u043e\u043c, \u043d\u043e \u043e\u043d\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435:<\/p>\n<p>  <b>\u0418\u0442\u0430\u043a, \u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0447\u0435\u0435\u043a<\/b><br \/>  \u0412 iOS8 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0432\u0432\u0435\u043b\u0438 out-of-the-box \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0447\u0435\u0435\u043a \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Layout Constraints (\u0445\u043e\u0442\u044f \u0438 \u0433\u043b\u044e\u0447\u0438\u043b\u043e \u043e\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e). \u0412 iOS9 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 Stack Views. \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0438 \u043e \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0447\u0438 \u043d\u0435\u0442. <\/p>\n<p>  \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u0438 \u044f\u0447\u0435\u0435\u043a \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e XIB-\u0430<\/p>\n<p>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u043e\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 UITableViewCell \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 constraint-\u0430\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 <i>tableView:heightForRowAtIndexPath:<\/i> \u0432 \u0442\u0430\u043a\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f item\/text \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u0438, \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <i>[cell layoutIfNeeded]<\/i>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <i>cell.frame.size.height<\/i>.<\/p>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043d\u0430\u0448\u0438\u043c\u0438 \u043f\u0440\u0435\u0434\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 NSDictionary, \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 .m \u0444\u0430\u0439\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <\/p>\n<pre><code class=\"objectivec\">#import &lt;objc\/runtime.h&gt;<\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 setCellPrototypes: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c NSDictionary \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438, \u0433\u0434\u0435 \u043a\u043b\u044e\u0447 \u2014 reuseIdentifier:  <\/p>\n<pre><code class=\"objectivec\">@implementation UITableView (XibCells) static char cellPrototypesKey; - (void)setCellPrototypes:(NSArray&lt;UITableViewCell *&gt; *)cellPrototypes {   NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:cellPrototypes.count];   for (UITableViewCell* cell in cellPrototypes) {       [self registerNib:[PrepopulatedNib nibWithObjects:@[cell]] forCellReuseIdentifier:cell.reuseIdentifier];       dict[cell.reuseIdentifier] = cell;   }   objc_setAssociatedObject(self, &cellPrototypesKey, cellPrototypes, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (NSArray*)cellPrototypes { return nil; } \/\/\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e warning-a - (UITableViewCell *)cellPrototypeWithIdentifier:(NSString *)reuseIdentifier {   NSDictionary* dict = (NSDictionary*)objc_getAssociatedObject(self, &cellPrototypesKey);   return dict[reuseIdentifier]; } @end <\/code><\/pre>\n<p>  \u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 cellPrototypeWithIdentifier: \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 .h \u0444\u0430\u0439\u043b, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435.  <\/p>\n<pre><code class=\"objectivec\">@interface UITableView (XibCells) @property (nonatomic, strong) IBOutletCollection(UITableViewCell) NSArray* cellPrototypes; - (UITableViewCell*)cellPrototypeWithIdentifier:(NSString*)reuseIdentifier; @end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u043e\u0434\u0435 datasource \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u0442\u044b:  <\/p>\n<pre><code class=\"objectivec\">- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {     id cellItem = _items[indexPath.section][indexPath.row];     MyTableViewCell* cell = [tableView cellPrototypeWithIdentifier:@&quot;Cell&quot;];     cell.item = cellItem;     [cell layoutIfNeeded];     return cell.frame.size.height; } <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043d\u0430\u0440\u043e\u0447\u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 all-in-one \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Proof of concept \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445.<br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/271701\/\"> http:\/\/habrahabr.ru\/post\/271701\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0410 \u0437\u0430\u043e\u0434\u043d\u043e \u0440\u0430\u0437 \u0438 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0447\u0435\u0435\u043a.<\/p>\n<p>  Disclaimer:<br \/>  \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0442\u043e\u0448\u043d\u043e\u0442\u0443 \u0438 \u0434\u044c\u044f\u0432\u043e\u043b\u0430, \u0441\u0442\u0430\u0440\u0438\u043a\u0430\u043c \u0438 \u0431\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0434\u0435\u0442\u044f\u043c \u043f\u0440\u043e\u0441\u044c\u0431\u0430 \u043d\u0435 \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<p>  <s>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/s> \u041f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u2014 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0430\u044f \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430. \u041d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, Xcode \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u0439\u043c\u0443 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043e\u043a, \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0431\u0430\u0433\u043e\u0432. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/956\/d65\/a0f\/956d65a0fb924a0d8b5829927f8eba96.png\"\/>  <\/p>\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-269019","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269019","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=269019"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269019\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}