Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. -(void)scrollSmartCalendar {
  2. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  3. formatter.dateFormat = @"d";
  4. NSString *stringDate = [formatter stringFromDate:[NSDate date]];
  5. NSInteger item = stringDate.intValue;
  6. NSIndexPath *index = [NSIndexPath indexPathForItem:item-2 inSection:0];
  7.  
  8. // scorre UICollectionView fino a mostrare il Giorno corrente
  9. [self.dayCollectionView scrollToItemAtIndexPath:index atScrollPosition:UICollectionViewScrollPositionLeft animated:YES];
  10. [self.dayCollectionView.collectionViewLayout collectionViewContentSize];
  11.  
  12. }
  13.  
  14. #pragma mark -
  15. #pragma mark change Day Month Selected
  16.  
  17. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  18.  
  19. if (collectionView.tag == KPCollectionViewTypeDay) {
  20.  
  21. NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:indexPath.item inSection:0];
  22. [collectionView scrollToItemAtIndexPath:newIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
  23. }
  24.  
  25. if (collectionView.tag == KPCollectionViewTypeMonth) {
  26.  
  27. NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:indexPath.item inSection:0];
  28. [collectionView scrollToItemAtIndexPath:newIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
  29.  
  30.  
  31. // Reload CollectionView With New Month
  32. [self.calendarFunction reloadCollectionView:self.dayCollectionView withNewMonthAtIndexPath:indexPath forArrayDay:self.dayArray andWeekDay:self.dayWeekArray];
  33.  
  34. // Remove Highlited Cell if Month is not current
  35. KPSmallMonthCell *monthCell = (KPSmallMonthCell *)[self.monthCollectionView cellForItemAtIndexPath:indexPath];
  36. [self.calendarFunction setCurrentMonthFromCollectionViewCell:monthCell atIndexPath:indexPath andAddObjectInArray:self.currentMonthArray];
  37. }
  38. }
  39.  
  40. #pragma mark -
  41. #pragma mark Reload Day CollectionView with New Month Selected
  42.  
  43. -(void)reloadCollectionView:(UICollectionView *)collectionView withNewMonthAtIndexPath:(NSIndexPath *)index forArrayDay:(NSMutableArray *)day andWeekDay:(NSMutableArray *)weekDay {
  44.  
  45. [day removeAllObjects];
  46. [weekDay removeAllObjects];
  47.  
  48. [KPSmallCalendarDayData buildSmartCalendarDayWithWeekArray:weekDay andDay:day fromMonth:index.item+1];
  49. [collectionView reloadData];
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement