mirror of
https://github.com/HackPlan/IQKeyboardManager.git
synced 2026-06-17 10:51:50 +08:00
- 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.
74 lines
2.3 KiB
Objective-C
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
|