首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未启动IBOutlet

未启动IBOutlet
EN

Stack Overflow用户
提问于 2013-05-22 23:59:16
回答 1查看 158关注 0票数 1

我正在试着用定制的单元格制作一个表格视图。

我已经创建了两个引用我的类CustomCell的文件.m和.h。代码如下:

代码语言:javascript
运行
复制
#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中的单元格,如下所示:

代码语言:javascript
运行
复制
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellsIdentifier ];
    if (cell == nil){
        UIViewController *tempVC = [[UIViewController alloc] initWithNibName:@"CustomCell" bundle:nil];
        cell = (CustomCell *)tempVC.view;
    }

当我启动我的应用程序时,标签显示文本集,图像视图显示正确的图像。但是按钮没有出现。事实上,当设置断点时,我发现我的按钮地址总是0x00000000 (意味着我的按钮没有启动)。

有人能帮我解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2013-05-23 15:19:16

我找到了问题所在。

在他的viewDidLoad中,我正在做:

代码语言:javascript
运行
复制
UINib *cellNib = [UINib nibWithNibName:@"myCells" bundle:nil];
    [self.tableView registerNib:cellNib forCellReuseIdentifier:CellsIdentifier];

但是因为我更改了我的.xib名称,所以我没有加载正确的接口。奇怪的是,我没有任何名为"myCells“的笔尖。也许我应该在我的项目上进行一次“整洁”。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16696442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档