Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)scrollSmartCalendar {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- formatter.dateFormat = @"d";
- NSString *stringDate = [formatter stringFromDate:[NSDate date]];
- NSInteger item = stringDate.intValue;
- NSIndexPath *index = [NSIndexPath indexPathForItem:item-2 inSection:0];
- // scorre UICollectionView fino a mostrare il Giorno corrente
- [self.dayCollectionView scrollToItemAtIndexPath:index atScrollPosition:UICollectionViewScrollPositionLeft animated:YES];
- [self.dayCollectionView.collectionViewLayout collectionViewContentSize];
- }
- #pragma mark -
- #pragma mark change Day Month Selected
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView.tag == KPCollectionViewTypeDay) {
- NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:indexPath.item inSection:0];
- [collectionView scrollToItemAtIndexPath:newIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
- }
- if (collectionView.tag == KPCollectionViewTypeMonth) {
- NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:indexPath.item inSection:0];
- [collectionView scrollToItemAtIndexPath:newIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
- // Reload CollectionView With New Month
- [self.calendarFunction reloadCollectionView:self.dayCollectionView withNewMonthAtIndexPath:indexPath forArrayDay:self.dayArray andWeekDay:self.dayWeekArray];
- // Remove Highlited Cell if Month is not current
- KPSmallMonthCell *monthCell = (KPSmallMonthCell *)[self.monthCollectionView cellForItemAtIndexPath:indexPath];
- [self.calendarFunction setCurrentMonthFromCollectionViewCell:monthCell atIndexPath:indexPath andAddObjectInArray:self.currentMonthArray];
- }
- }
- #pragma mark -
- #pragma mark Reload Day CollectionView with New Month Selected
- -(void)reloadCollectionView:(UICollectionView *)collectionView withNewMonthAtIndexPath:(NSIndexPath *)index forArrayDay:(NSMutableArray *)day andWeekDay:(NSMutableArray *)weekDay {
- [day removeAllObjects];
- [weekDay removeAllObjects];
- [KPSmallCalendarDayData buildSmartCalendarDayWithWeekArray:weekDay andDay:day fromMonth:index.item+1];
- [collectionView reloadData];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement