This commit is contained in:
2026-02-02 14:29:42 +08:00
parent fe59a0cb45
commit 48c90fa0be
5 changed files with 159 additions and 13 deletions

View File

@@ -151,6 +151,14 @@
[self loadPersonas];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
KBPersonaChatCell *cell = [self currentPersonaCell];
if (cell) {
[cell onBecameCurrentPersonaCell];
}
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
if (self.bottomMaskLayer) {
@@ -387,8 +395,27 @@
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
CGFloat pageHeight = scrollView.bounds.size.height;
NSInteger currentPage = scrollView.contentOffset.y / pageHeight;
NSInteger previousIndex = self.currentIndex;
self.currentIndex = currentPage;
if (previousIndex != self.currentIndex) {
NSIndexPath *prevPath = [NSIndexPath indexPathForItem:previousIndex inSection:0];
KBPersonaChatCell *prevCell = (KBPersonaChatCell *)[self.collectionView cellForItemAtIndexPath:prevPath];
if (prevCell) {
[prevCell onResignedCurrentPersonaCell];
}
KBPersonaChatCell *currentCell = [self currentPersonaCell];
if (currentCell) {
[currentCell onBecameCurrentPersonaCell];
}
} else {
KBPersonaChatCell *currentCell = [self currentPersonaCell];
if (currentCell) {
[currentCell onBecameCurrentPersonaCell];
}
}
if (currentPage < self.personas.count) {
NSLog(@"当前在第 %ld 个人设:%@", (long)currentPage, self.personas[currentPage].name);
// persona AppGroup使