[英]How can I add an interactive view controller inside of a UITableViewCell?
在我的項目中,我有一個UITableView,其中包含水平滾動的UICollectionViews。 因此,表視圖中的每個單元格都是一個新的集合視圖。 我需要在每個單元格的左側都有一個交互式視圖。 該視圖將沿左側折疊,但是如果您點擊該視圖,它將使動畫稍微打開。 如果將集合視圖一直滾動到最左側,即開始,則它將打開。 用戶開始滾動集合視圖后,它將自動關閉。
這是一個視覺示例:
表格視圖單元格
The view is collapsed in this image.
____________________________
|V | |
|i | CollectionView |
|e | Scrolls </> |
|w_|_______________________|
The view is open in this image. The ways it opens are described above.
____________________________
|V | |
|i | CollectionView |
|e | Scrolls </> |
|w______|__________________|
如何將這個交互式控制器放置在單元格的左側,該單元格中已經具有集合視圖?
另外,如果有類似這樣的事情的第三方控制,那就太好了!
那將是一個UIView
不是UIViewController
放在UICollectionView
的左側。
在UICollectionView
委托方法cellForItemAtIndexPath
,可以在第一個集合視圖單元格可見時展開和縮回cellLeftSideView
:
if ([[cell_CollectionView indexPathsForVisibleItems] containsObject:[NSIndexPath indexPathForItem:0 inSection:0]]) {
// First item IS showing in collection view
// Make sure left side view is expanded
[UIView animateWithDuration:0.5 animations:^{
CGRect aFrame = cell_LeftSideView.frame;
aFrame.size.width = kCellLeftSideView_Width_Max; // <= #define maximum width value
cell_LeftSideView.frame = aFrame;
}];
}
else
{
// First item is NOT showing in collection view
// Make sure left side view is shrunk
[UIView animateWithDuration:0.5 animations:^{
CGRect aFrame = cell_LeftSideView.frame;
aFrame.size.width = kCellLeftSideView_Width_Min; // <= #define minimum width value
cell_LeftSideView.frame = aFrame;
}];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.