- (void) segmentedAction:(id)sender {
if ([sender
isKindOfClass:[UISegmentedControl class]])
{
UISegmentedControl * segment = sender;
[_sectionArray enumerateObjectsUsingBlock:^(id
_Nonnull obj, NSUInteger idx, BOOL * _Nonnull
stop)
{
if (segment.selectedSegmentIndex == idx)//
{
if
(self.collectionloaded)
{
segmented.selectedSegmentIndex
= idx;
// scroll to selected
index
NSIndexPath* cellIndexPath =
[NSIndexPath indexPathForItem:0 inSection:idx];
UICollectionViewLayoutAttributes* attr =
[myCollenctionV.collectionViewLayout
layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader
atIndexPath:cellIndexPath];
UIEdgeInsets insets =
myCollenctionV.scrollIndicatorInsets;
CGRect rect =
attr.frame;
rect.size =
myCollenctionV.frame.size;
rect.size.height -= insets.top
+ insets.bottom;
CGFloat offset =
(rect.origin.y + rect.size.height) -
myCollenctionV.contentSize.height;
if ( offset > 0.0 ) rect =
CGRectOffset(rect, 0, -offset);
[myCollenctionV
scrollRectToVisible:rect animated:YES];
}
}
}];
}
}
加载中,请稍候......