我創建了一個自定單元:Xcode的定製細胞與IBOutlet中的對象和不
#import <UIKit/UIKit.h>
#import "SevenSwitch.h"
@interface cellaMain : UITableViewCell {
SevenSwitch *subscribed;
}
@property (nonatomic, retain) IBOutlet UIImageView *imageMain;
@property (nonatomic, retain) IBOutlet UILabel *titleMain;
@property (nonatomic, retain) SevenSwitch *subscribed;
@end
的UIImage的和標籤由故事板添加到細胞,但sevenswitch在所述方法中加入:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
有了這個代碼:
/* Switch Inside the cell */
cella.subscribed = [[SevenSwitch alloc] initWithFrame:CGRectMake(cella.frame.size.width-60, cella.frame.size.height/2 - 12, 50, 25)];
cella.subscribed.offImage = [UIImage imageNamed:@"off.png"];
cella.subscribed.onImage = [UIImage imageNamed:@"on.png"];
cella.subscribed.thumbTintColor = [UIColor colorWithRed:(230/255.0) green:(230/255.0) blue:(230/255.0) alpha:1];
cella.subscribed.activeColor = [UIColor colorWithRed:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:1];
cella.subscribed.inactiveColor = [UIColor colorWithRed:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:1];
cella.subscribed.onTintColor = [UIColor colorWithRed:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:1];
cella.subscribed.isRounded = NO;
cella.subscribed.tag = [[tempCat objectForKey:@"Id"] intValue];
[cella.subscribed addTarget:self action:@selector(changeSingleCategory:) forControlEvents:UIControlEventValueChanged];
if ([[tempCat objectForKey:@"Subscribed"] isEqualToString:@"Y"]) {
cella.subscribed.on = YES;
} else {
cella.subscribed.on = NO;
}
[cella.contentView addSubview:cella.subscribed];
/* End Switch Editing */
的問題是,滾動落後了很多。 如何添加cellaMain.m中的SevenSwitch對象,並讓圖片和標籤由Storyboard添加? 或者,也許是更好的添加到我的細胞查看我cellaMain.m文件中的所有對象(標籤,圖像和SeveSwitch)?
明天一到我就去辦公室我嘗試這個解決方案...我認爲這可能是正確的... – prelite
我忍不住要等到明天......一切正常,SevenSwitch是一個UIControl Class對象,故事板,而不是UISwitch我添加了一個UIView分配它SevenSwitch類...謝謝soooooo ... – prelite
很高興爲您提供幫助..乾杯。 :-) – iphonic