bla*_*bus 4 iphone xcode uitableview iboutlet
我在Xcode 4中为我的iPhone应用程序创建自定义tableview单元时遇到了问题.我创建了.h和.m文件,为单元格内应存在的所有子视图创建了IBOutlets,并进行了拖动Interface Builder中对单元格的XIB文件的实际控制.但是,我无法弄清楚如何将插座连接到IB控件.我读过的每个教程都说控制 - 从对象列表中的TableViewCell对象拖动到子视图,但是当我这样做时,我的IBOutlets没有列在弹出窗口中.唯一可用的插座是'acccessoryView','backgroundView','editingAccessoryView'和'backgroundSelectedView'.我不也应该在该列表中看到自己的IBOutlets吗?或者我没有遵循正确的程序?(我对iPhone开发很新).
这是我用于自定义单元类的代码:
.H :
//
// RecommendationCell.h
// Tuneplug
//
// Created by Bill Labus on 6/21/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RecommendationCell : UITableViewCell {
UIImageView *artwork;
}
@property (nonatomic, retain) UIImageView *artwork;
@end
Run Code Online (Sandbox Code Playgroud)
.m:
//
// RecommendationCell.m
// Tuneplug
//
// Created by Bill Labus on 6/21/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "RecommendationCell.h"
@implementation RecommendationCell
@synthesize artwork;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc
{
[super dealloc];
}
@end
Run Code Online (Sandbox Code Playgroud)
(请注意,我现在将子视图缩小为"图稿"图像视图,以简化计算).谢谢你的帮助!
除非我误解:
尝试添加IBOutlet标记.
IBOutlet UIImageView *artwork;
Run Code Online (Sandbox Code Playgroud)
和
@property (nonatomic, retain) IBOutlet UIImageView *artwork;
Run Code Online (Sandbox Code Playgroud)
此标记是Xcode中的#define,它告诉Interface Builder识别您的代码.
| 归档时间: |
|
| 查看次数: |
5932 次 |
| 最近记录: |