Из моего другого вопроса; Использование UITableViewCell в UITableView Я использовал 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 - это синтезировал предметы
Тогда у меня есть пользовательская ячейка:
![enter image description here](https://i.stack.imgur.com/wLMHB.png)
![enter image description here](https://i.stack.imgur.com/teGgp.png)
![enter image description here](https://i.stack.imgur.com/9f9yr.png)
Отсюда я немного застрял, я не могу понять, как установить два свойства метки из моего ViewRoutes.m (в конечном итоге они будут приходить из xml, но пока только с изменяемым массивом)
Правильно ли я делаю это?
Tom
Редактировать Просто чтобы вы знали, я сейчас загружаю строку изображения в метку, позже будет изображение