從我的其他問題; Using UITableViewCell in a UITableView我用IB創建了一個自定義單元格。繼承人如何我的代碼是目前:UITableViewCell使用IB加載數據的自定義單元格
ViewRoutes(原始表)
.h
@interface ViewRoutes : UIViewController {
IBOutlet UITableView *tblRoute;
}
@property(nonatomic, retain) UITableView *tblRoute;
@end
.M
#import "ViewRoutes.h"
#import "ViewRoutesCell.h"
@implementation ViewRoutes
@synthesize tblRoute;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (NSInteger)
numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell * aCell = [tableView dequeueReusableCellWithIdentifier:@"ViewRoutesCell"];
if (aCell == nil)
{
NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"ViewRoutesCell" owner:self options:nil];
for (NSObject *anObj in arr) {
if([anObj isKindOfClass:[UITableViewCell class]]) {
aCell = (UITableViewCell *)anObj;
}
return aCell;
}
}
}
和的.xib只是上有一個UITableView。
的ViewRoutesCell(我想成爲自定義單元格是什麼)
.H
#import <UIKit/UIKit.h>
@interface ViewRoutesCell : UITableViewCell {
IBOutlet UITableViewCell *routesCell;
NSMutableArray *arryRouteText;
NSMutableArray *arryRouteImage;
IBOutlet UILabel *lblRouteText;
IBOutlet UILabel *lblRouteImage;
}
@property (nonatomic, retain) NSMutableArray *arryRouteText;
@property (nonatomic, retain) NSMutableArray *arryRouteImage;
@property (nonatomic, retain) UILabel *lblRouteText;
@property (nonatomic, retain) UILabel *lblRouteImage;
@end
我已經在自定義單元格的.m做的唯一的事情是合成的物品
然後我的自定義單元格的xib我有:
從這裏我得到一點點堅持,我不能工作了如何從我的ViewRoutes.m設定的兩個標籤屬性(它們將從XML最終會到來,但是現在只要一個可變陣列)
我正在做這個正確的方法嗎?
湯姆
編輯只是爲了讓你知道我加載圖像串的標籤就目前而言,將是一個圖像後
它是什麼,你想做的事是什麼呢?您是否嘗試編輯自定義單元格的標籤屬性,或者您是否嘗試編輯ViewRoutes.m文件的屬性? – Warkst
我試圖從ViewRoutes.m編輯自定義單元格的標籤屬性 – TMB87