У меня есть uitableview, а не контроллер uitableview. И я хочу загрузить url внутри uitableview, но метод viewdidload не работает в методе uitableview. Как я могу загрузить URL в файле uitableview
.m
#import "HHContentTableView.h"
#import "MyCustomCell.h"
@interface HHContentTableView ()<UITableViewDataSource, UITableViewDelegate>
@end
@implementation HHContentTableView
+ (HHContentTableView *)contentTableView
{
HHContentTableView *contentTV = [[HHContentTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
contentTV.backgroundColor = [UIColor clearColor];
contentTV.dataSource = contentTV;
contentTV.delegate = contentTV;
[contentTV registerNib:[UINib nibWithNibName:@"MyCustomCell" bundle:nil] forCellReuseIdentifier:@"myCell"];
return contentTV;
}
#pragma mark - UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCustomCell * cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
if (!cell)
{
[tableView registerNib:[UINib nibWithNibName:@"MyCustomCell" bundle:nil] forCellReuseIdentifier:@"myCell"];
cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
}
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(MyCustomCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.leftLabel.text = [NSString stringWithFormat:@"%@",@(indexPath.row)];
cell.rightLabel.text = [NSString stringWithFormat:@"%@",@(indexPath.row)];
cell.middleLabel.text = [NSString stringWithFormat:@"%@",@(indexPath.row)];
}
.h файл
#import <UIKit/UIKit.h>
@interface HHContentTableView : UITableView
+ (HHContentTableView *)contentTableView;
@end
См. Пример проекта HHHorizontPagingView, чтобы понять больше.