Files
IQKeyboardManager/Demo/Objective_C_Demo/ViewController/CollectionViewDemoController.m
hackiftekhar 6becc06ca3 - Converted Obj-C demo with Autolayout
- Enhanced demo project and added various examples demonstrating almost all properties of library.
- Enhanced library Settings Controller.
- Moved some contents of README.md file to other files.
2016-05-22 23:13:04 +05:30

74 lines
2.3 KiB
Objective-C

//
// CollectionViewDemoController.m
// IQKeyboard
//
// Created by Iftekhar on 29/10/14.
// Copyright (c) 2014 Iftekhar. All rights reserved.
//
#import "CollectionViewDemoController.h"
@interface CollectionViewDemoController ()<UICollectionViewDelegate,UIPopoverPresentationControllerDelegate>
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;
@end
@implementation CollectionViewDemoController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 20;
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TextFieldCollectionViewCell" forIndexPath:indexPath];
UITextField *textField = (UITextField*)[cell viewWithTag:10];
textField.placeholder = [NSString stringWithFormat:@"%ld, %ld", (long)indexPath.section, (long)indexPath.row];
return cell;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"SettingsNavigationController"])
{
segue.destinationViewController.modalPresentationStyle = UIModalPresentationPopover;
segue.destinationViewController.popoverPresentationController.barButtonItem = sender;
CGFloat heightWidth = MAX(CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight([[UIScreen mainScreen] bounds]));
segue.destinationViewController.preferredContentSize = CGSizeMake(heightWidth, heightWidth);
segue.destinationViewController.popoverPresentationController.delegate = self;
}
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return UIModalPresentationNone;
}
-(void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController
{
[self.view endEditing:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (BOOL)shouldAutorotate
{
return YES;
}
@end