我用了很多在我UITableViewCells不同的UI元素太大,爲什麼不嘗試和子類的UITableViewCell並推出自己的類,以項目爲屬性的示例細胞?似乎爲我工作。
在VincentsAwesomeCell.h :
@interface VincentsAwesomeCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *FooLabel;
@property (weak, nonatomic) IBOutlet UILabel *BarLabel;
@property (weak, nonatomic) IBOutlet UIImageView *ShimmyIcon;
@property (weak, nonatomic) IBOutlet UILabel *DooWopLabel;
@property (weak, nonatomic) IBOutlet UIImageView *UseIcon;
@property (weak, nonatomic) IBOutlet UILabel *TheForceLabel;
@property (weak, nonatomic) IBOutlet UIImageView *bobSledIcon;
@property (weak, nonatomic) IBOutlet UILabel *WristWatchLabel;
@property (weak, nonatomic) IBOutlet UILabel *MeatLoafLabel;
@property (weak, nonatomic) IBOutlet UILabel *SciFiLabel;
@property (weak, nonatomic) IBOutlet UILabel *CollinderLabel;
@property (weak, nonatomic) IBOutlet UILabel *RhubarbLabel;
@property (weak, nonatomic) IBOutlet UITextField *SuperTextField;
@property (weak, nonatomic) IBOutlet UIStepper *stepper;
@property (strong, nonatomic) IBOutlet UILabel *amountOfAwesomeness;
不要忘記使用:
在VincentsAwesomeCell.m:
- (void)prepareForReuse {
[super prepareForReuse];
// Always call this!
// Reset custom stuff
}
重置細胞的屬性重用。
- (void) viewDidLoad
{
[super viewDidLoad];
// Register the custom VincentsAwesomeCell NIB with the tableview
UINib *nib = [UINib nibWithNibName:@"VincentsAwesomeCell" bundle:nil];
[[self tableView] registerNib:nib forCellReuseIdentifier:@"VincentsAwesomeCell"];
}
對於
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
我用這一個UIStepper跟蹤哪個被壓例如步進:
[[cell stepper]setTag:indexPath.row];
[[cell stepper]addTarget:self action:@selector(stepperChanged:) forControlEvents:UIControlEventValueChanged];
在TableViewController.m
然後
希望這會有所幫助!
P.S.
我使用的.xib文件創建的佈局設計我的自定義單元格的。只需將UITableViewCell拖入InterFaceBuilder並自定義即可!不要忘記鏈接屬性!
iOS HIG:*「應用程序響應手勢,而不是點擊」* http://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/Characteristics/Characteristics.html#//apple_ref/doc/uid/TP40006556-CH7-SW4 – Felix
@ phix23 - 是啊,但它是如何應用於我的情況? – itsaboutcode
組自定義對象userInteractionEnabled沒有 – NANNAV