Files
IQKeyboardManager/Demo/Objective_C_Demo/ViewController/TableViewInContainerViewController.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

84 lines
2.7 KiB
Objective-C

//
// TableViewInContainerViewController.m
// IQKeyboard
//
// Created by Jeffrey Sambells on 2014-12-05.
// Copyright (c) 2014 Iftekhar. All rights reserved.
//
#import "TableViewInContainerViewController.h"
@interface TableViewInContainerViewController ()<UIPopoverPresentationControllerDelegate>
@end
@implementation TableViewInContainerViewController
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 30;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"TestCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.backgroundColor = [UIColor clearColor];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10,0,cell.contentView.frame.size.width-20,33)];
textField.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleWidth;
textField.center = cell.contentView.center;
[textField setBorderStyle:UITextBorderStyleRoundedRect];
textField.tag = 123;
[cell.contentView addSubview:textField];
}
UITextField *textField = (UITextField *)[cell.contentView viewWithTag:123];
textField.placeholder = [NSString stringWithFormat:@"Cell %@",@(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