Created
February 9, 2010 22:15
-
-
Save jon/299752 to your computer and use it in GitHub Desktop.
A table view containing a single editable text field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BPTextFieldViewController.h | |
// | |
// Created by Jon Olson on 10/2/09. | |
// Copyright 2009 Ballistic Pigeon, LLC. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface BPTextFieldViewController : UITableViewController { | |
UITableViewCell *cell; | |
UITextField *textField; | |
} | |
@property (readonly) UITextField *textField; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BPTextFieldViewController.m | |
// | |
// Created by Jon Olson on 10/2/09. | |
// Copyright 2009 Ballistic Pigeon, LLC. All rights reserved. | |
// | |
#import "BPTextFieldViewController.h" | |
@implementation BPTextFieldViewController | |
- (UITextField *)textField { | |
self.view; | |
return textField; | |
} | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
self.tableView.allowsSelection = NO; | |
textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 6, self.tableView.frame.size.width - 40, 31)]; | |
textField.borderStyle = UITextBorderStyleNone; | |
textField.autoresizingMask = UIViewAutoresizingFlexibleWidth; | |
textField.font = [UIFont systemFontOfSize:15.0]; | |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; | |
[cell.contentView addSubview:textField]; | |
} | |
- (void)viewDidUnload { | |
[textField release]; | |
textField = nil; | |
[cell release]; | |
cell = nil; | |
} | |
#pragma mark Table view methods | |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | |
return 1; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | |
return 1; | |
} | |
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { | |
return 45.0; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
return cell; | |
} | |
- (void)dealloc { | |
[textField release]; | |
[cell release]; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment