1
我正在嘗試使用自定義單元格的tableview。IBOutlet未啓動
我創建了2個文件.m和.h,它們指向我的類CustomCell。 下面是代碼:
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell
{
IBOutlet UIImageView *miniLogo;
IBOutlet UILabel *cellText;
IBOutlet UIButton *deleteButton;
}
@property (strong, nonatomic) IBOutlet UIImageView *miniLogo;
@property (strong, nonatomic) IBOutlet UILabel *cellText;
@property (strong, nonatomic) IBOutlet UIButton *deleteButton;
@end
-------------------------------------------------------------
#import "CustomCell.h"
@implementation CustomCell
@synthesize miniLogo,cellText, deleteButton;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
-(void)layoutSubviews{
[super layoutSubviews];
}
/*
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}*/
@end
憑藉的.xib文件,我設計了我的手機,並連接IBOutlets,並設置單元格的標識。
在該表中與用戶自己定製的細胞,我稱之爲細胞的方法的tableView:cellForRowAtOndexPath:是這樣的:
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellsIdentifier ];
if (cell == nil){
UIViewController *tempVC = [[UIViewController alloc] initWithNibName:@"CustomCell" bundle:nil];
cell = (CustomCell *)tempVC.view;
}
當我啓動我的應用程序,標籤顯示設置的文本,圖像意見顯示正確的圖像。但按鈕不出現。事實上,當設置斷點時,我看到我的按鈕的地址始終爲0x00000000(意味着我的按鈕未啓動)。
請問有人可以幫我解決這個問題。
您確定您已連接IB的deleteButton插座嗎? –
將它們帶出界面。你不需要它們被合成和自動合成 –
我的按鈕連接到我的.h文件。 我在界面中刪除了我的IBOutlet,但沒有更改.... – zbMax