J'ai créé un CustomView ganttChartView et l'ai ajouté à partir du storyboard. Maintenant, sur ganttChartView, j'ai une vue UICollection qui représentera timeLine et sera ajoutée par programmation.Autoresignalisation des sous-vues (UICollectionView) sur le changement d'orientation
// Initialize GanttChat View from Interface Builder or Storyboard File
-(id)initWithCoder:(NSCoder *)aDecoder
{
self= [super initWithCoder:aDecoder];
if (self) {
self.timeLineHeight =KMinTimeLineCellHeight;
self.timeLineCellWidth=kMinTimeLineCellWidth;
self.backgroundColor = [UIColor redColor];
self.autoresizesSubviews = YES;
}
return self;
}
-(void)reloadTimelineView
{
[self initializeTimeLineView];
[self.timeLineCollectionView reloadData];
}
-(void) initializeTimeLineView
{
// Initialization of StartDate End Date and DateMode Property
[self initializeTimeLineDates];
// Creating Layout for Collection view
UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
CGSize cellSize =CGSizeMake(self.timeLineCellWidth, self.timeLineHeight) ;
flowLayout.itemSize = cellSize ;
flowLayout.minimumInteritemSpacing= 1.0f;
flowLayout.minimumLineSpacing=5.0f;
CGRect timeLineFrame =CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, self.timeLineHeight);
// Initialization of CollectionView for TimeLine
self.timeLineCollectionView = [[UICollectionView alloc] initWithFrame:timeLineFrame collectionViewLayout:flowLayout];
[self.timeLineCollectionView registerClass:[A3TimeLineCollectionViewCell class] forCellWithReuseIdentifier:timeLineCell_ID];
self.timeLineCollectionView.backgroundColor = self.timeLineBackgroundColor;
// Initialization of CollectionView DataSource and Delegate with Start Date and End date and DateMode
self.timeLineDataSource = [[A3GanttChartTimeLineDelegate alloc] initWithDate:self.startDate andDate:self.endDate withMode:self.dateType];
self.timeLineDataSource.gantChartView = self;
self.timeLineDataSource.timeLineEachCellColor = self.timeLineEachCellColor;
self.timeLineCollectionView.delegate=self.timeLineDataSource;
self.timeLineCollectionView.dataSource=self.timeLineDataSource;
[self addSubview:self.timeLineCollectionView];
}
Maintenant Storyboard J'ai option AutoLayout personnes handicapées et de la taille de l'inspecteur ganttChartView j'ai mis en coin supérieur gauche et fixé de façon à redimensionnée après le changement d'orientation.
Maintenant, le problème est que TimeLineCollection View ne redimensionne sur le changement d'orientation du paysage. Comme son ajouté par programme Donc ce que je dois faire le faire redimensionner sur le changement d'orientation.
Bénéfice mode
mode paysage
Merci pour votre réponse, mais cela n'a pas fonctionné pour moi. Est-il possible que nous utilisions NSLayoutConstraint par programme pour résoudre ce problème. –