I am developing a uiCollection view, In which i have 4 cells, on 4th cell i have uiview which hold button and ui textview. once i tap button the textview should reveal and close.
I don't know how to handle this, how to increase particular cell size on inaction in cell object
UICollectionview.M
#pragma mark - UICollectionView DataSource & Delegate methods
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 4;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section==2) {
UICollectionViewCell * cell =[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier2 forIndexPath:indexPath];
return cell;
}
else if(indexPath.section==1){
UICollectionViewCell * cell =[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier1 forIndexPath:indexPath];
return cell;
}
else if(indexPath.section==0){
UICollectionViewCell * cell =[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
return cell;
}
else{
infoCell * cell =[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier3 forIndexPath:indexPath];
return cell;
}
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 3) {
return CGSizeMake(self.width, self.height);
}
else{
return CGSizeMake(309, 300);
}
}
@end
cell object
cellobject.h
@interface InfoCell : UICollectionViewCell
{
BOOL toggleIsOn;
}
@property (weak, nonatomic) IBOutlet UIView *infoView;
@property (weak, nonatomic) IBOutlet UIButton *dropDownButton;
@property (weak, nonatomic) IBOutlet UITextView *infoDescrip;
@end
cell object.m
-(IBAction)revealDescription:(id)sender{
if (toggleIsOn)
{
self.infoDescrip.hidden= YES;
self.infoView.frame=CGRectMake(0, 0, 309,44);
}
else
{
self.infoDescrip.hidden= NO;
NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:14]};
CGRect rect = [self.infoDescrip.text boundingRectWithSize:CGSizeMake(300, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin
attributes:attributes context:nil];
self.infoDescrip.frame= CGRectMake(0, 46, 300, rect.size.height);
self.infoView.frame=CGRectMake(0, 0, 309, rect.size.height+50);
}
toggleIsOn = !toggleIsOn;
[self.dropDownButton setImage:[UIImage imageNamed:toggleIsOn ? @"arrow_down_blue" :@"arrow_right_blue"] forState:UIControlStateNormal];
}
I am struggling to get out of this any help?
Aucun commentaire:
Enregistrer un commentaire