Skip to content

Instantly share code, notes, and snippets.

@gfontenot
Created October 23, 2012 19:05
Show Gist options
  • Save gfontenot/3940888 to your computer and use it in GitHub Desktop.
Save gfontenot/3940888 to your computer and use it in GitHub Desktop.
UISwitchCell
//
// UISwitchCell.h
// Hops
//
// Created by Gordon on 9/10/10.
// Copyright 2010 Gordon Fontenot. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol UISwitchCellDelegate
- (void)switchDidToggle:(id)sender;
@end
@interface UISwitchCell : UITableViewCell {
UISwitch *cellSwitch;
}
@property (nonatomic) id <UISwitchCellDelegate> delegate;
@property (nonatomic) UISwitch *cellSwitch;
-(id)initWithDelegate:(id <UISwitchCellDelegate>)delegate;
@end
//
// UISwitchCell.m
// Hops
//
// Created by Gordon on 9/10/10.
// Copyright 2010 Gordon Fontenot. All rights reserved.
//
#import "UISwitchCell.h"
@implementation UISwitchCell
@synthesize cellSwitch, delegate;
- (id)initWithDelegate:(id<UISwitchCellDelegate>)delegate {
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SwitchCell"])) {
// Initialization code
self.delegate = delegate;
cellSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(224, 10, 0, 0)];
[cellSwitch addTarget:self.delegate action:@selector(switchDidToggle:) forControlEvents:UIControlEventValueChanged];
[self addSubview:cellSwitch];
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment