
نعم نعم. وأنا أفهم أنه من عام 2020، أن جميع المطورين IOS المتشددين إرسال حصرا في SwiftUIو Combine، وكتابة مقالات عن UIKitشيء من هذا القبيل "لا الجليد". ومع ذلك ، تبين أن عام 2020 مختلف عن جميع السنوات السابقة. لا على الإطلاق مثل هذا.
لذلك ، بمجرد أن ضرب الإغلاق الكامل دبلن في مكان ما في منتصف شهر مارس ، بدأت في البحث عن شيء أفعله بنفسي في الأمسيات الباردة الممطرة. وقد دلل نفسك SwiftUIو Combine، وبعد أن قررت أن أنا بالتأكيد لا تريد أن تكون اختبار ألفا العام، على الرغم من أن أجد كل هذا خطوة في الاتجاه الصحيح، وأنا قررت أن ننظر أعمق في آخر ما أثار اهتمامي، ولكن كان هناك دائما لا وقت لأنها من أصل الرقم. في هذه اللحظة بالذات ، قررت شركة WebSummit ، التي بدأت العمل فيها مؤخرًا ، تغيير دردشة المزود واضطررت إلى التعمق أكثر في تطبيق الدردشة الحالي.
MessageKit UI . MessageKit — swift , , JSQMessagesViewController. JSQMessagesViewController 5 . , , UIKit , , , swift- . , UI JSQMessagesViewController. 2020-.
MessageKit 2020-. JSQMessagesViewController Objective-C Swift IOS 2009 . , .
, issues, , , — .
UIScrollView , , “” . 99% , , . “” (contentOffset) .
. - UICollectionViewFlowLayout. ?
, UICollectionViewLayout UICollectionViewFlowLayout, MessageKit Auto-Layout . , UICollectionViewFlowLayout .
. UICollectionViewLayout . . UICollectionViewLayout.
.
, ,
. UICollectionViewLayout . . .
, , , , , , . 4 .
UICollectionViewLayout 2 :
initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes?
finalLayoutAttributesForDisappearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes?
initialLayoutAttributesForAppearingItem finalLayoutAttributesForDisappearingItem
initialLayoutAttributesForAppearingItem :
When your app inserts new items into the collection view, the collection view calls this method for each item you insert. Because new items are not yet visible in the collection view, the attributes you return represent the item’s starting state. For example, you might return attributes that position the item offscreen or set its initial alpha to 0. The collection view uses the attributes you return as the starting point for any animations. (The end point of the animation is the item’s new location and attributes.) If you return nil, the layout uses the item’s final attributes for both the start point and end point of the animation.
The default implementation of this method returns nil. Subclasses are expected to override this method, as needed, and provide any initial attributes.
, , , . finalLayoutAttributesForDisappearingItem . ,
If you return nil, the layout uses the item’s final attributes for both the start point and end point of the animation.
.
. . , c itemIndexPath? 0. 0 — 1? ? 0 0 2?
, , , . : , , . , IOS 12 IOS 13 . . .
UICollectionViewFlowLayout , ChatLayout, , , , .
UICollectionViewFlowLayout , .
, . / UICollectionViewFlowLayout private API … Apple UIKit. , . , , , . , / UICollectionViewFlowLayout. .
AutoLayout

AutoLayout. . ? ? , ? - -?
UICollectionViewLayout . . , . UICollectionViewFlowLayout , prepare , . , AutoLayout .
, : airbnb/MagazineLayout. . . , initialLayoutAttributesForAppearingItem /finalLayoutAttributesForDisappearingItem , AirBnB.
. , " " — ! , .
: UICollectionViewLayoutAttributes, , initialLayoutAttributesForAppearingItem, invalidationContext(forPreferredLayoutAttributes:, withOriginalAttributes originalAttributes:) frame UICollectionView KVO (Key-Value-Observing) . preferredAttributes, originalAttributes. . .
, , . UIScrollView , , , , , .
, . adjustedContextInsets, , .
, UICollectionViewLayout. , . UICollectionViewLayout targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint , UICollectionView : , , , contentOffset , — .
, , , , . , UICollectionViewLayoutInvalidationContext contentOffsetAdjustment, . 2 , proposedContentOffset — , , finalizeCollectionViewUpdates. .
, , AutoLayout . UICollectionView (contentSize) contentOffsetAdjustment , , : contentSizeAdjustment , contentOffset . .
.
private API

, , . . , , rdar://40926834: Self Sizing + Prefetching Bugs AirBnB. , .
rdar://46865293: Cell's autoresizing mask breaks self-sizing. layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? , .
, MagazineLayout UICollectionViewFlowLayout _prepareForCollectionViewUpdates:withDataSourceTranslator: prepareForCollectionViewUpdates. Apple, UIKit. : — UICollectionView prepareForCollectionViewUpdates. .
IOS , UICollectionView .. .. — .
, , . , . , , UIKit . .
, UICollectionView + UICollectionViewLayout . , , — . contentInset, , , — . — . — . ? UICollectionViewFlowLayout — UICollectionView + UICollectionViewLayout , , " ". , -, , : — / ..
?

, , . MessageKit ChatLayout. , MessageKit . .
UIViewController . — . , , . , , / master.
MessageKit. . . Jira .
?
, , , preview, . , , - , , , , . .
, . .. . : -. . RouteComposer. , , 2 open-source . , , .
, .
ChatLayout — UI . , UICollectionViewLayout, , . , Extras UIView, , , - .
- (
UICollectionViewCell)UIView(UICollectionReusableView). - /// .
-
contentOffsetUICollectionView. - .
-
UIView-, .
(, -, )
ChatLayout UICollectionViewLayout, :
-
UIViewControllerUICollectionView. . , -
UICollectionViewCell. , . - .
ChatLayout. , , . , — . - . .
UICollectionViewDataSource. - DifferenceKit, . ChatLayout. . — contentInsetsUICollectionView.ChatLayout. - InputBarAccessoryView ( ,MessageKit). .
. . .
نعم بالتأكيد. صور GIF. (الحذر لمرضى الصرع)
