Skip to content

Instantly share code, notes, and snippets.

@chipp
Created September 6, 2011 18:22
Show Gist options
  • Save chipp/1198512 to your computer and use it in GitHub Desktop.
Save chipp/1198512 to your computer and use it in GitHub Desktop.
custom view cell
//
// ChildEditTableViewCell.h
// BabyBook
//
// Created by Vladimir Burdukov on 8/31/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ChildEditTableViewCell : UITableViewCell
@property (nonatomic, retain) UITableView *parentTableView;
@property (nonatomic, retain) UITextField *field;
@end
//
// ChildEditTableViewCell.m
// BabyBook
//
// Created by Vladimir Burdukov on 8/31/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "ChildEditTableViewCell.h"
@implementation ChildEditTableViewCell
@synthesize parentTableView, field;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
// Initialization code
}
return self;
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[self setNeedsLayout];
}
- (void)layoutSubviews
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[super layoutSubviews];
CGRect contentFrame = self.contentView.frame;
contentFrame.origin.x = 10;
self.contentView.frame = contentFrame;
if (field)
if (((UITableView *)self.superview).isEditing)
field.userInteractionEnabled = YES;
else
field.userInteractionEnabled = NO;
[UIView commitAnimations];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment