Created
October 23, 2012 19:05
-
-
Save gfontenot/3940888 to your computer and use it in GitHub Desktop.
UISwitchCell
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
// | |
// 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 |
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
// | |
// 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