輸入 "YBLeftView.h"
@interface YBLeftView()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UIView *myLeftView;
@property(nonatomic,strong)NSMutableArray *tableDataArray;
@property(nonatomic,strong)UITableView *tableView;
@end
財産の//初期化を表示することはできません。私は私のビュークラスでのtableViewを書き、それがデータソース
@implementation YBLeftView
-(instancetype)init
{
UIView *myLeftView=[[UIView alloc]initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width/3,[UIScreen mainScreen].bounds.size.height)];
myLeftView.backgroundColor=[UIColor colorWithRed:26/256.f green:31/256.f blue:36/256.f alpha:0.7];
//tableView
UITableView *tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 114, myLeftView.bounds.size.width, myLeftView.bounds.size.height-164) style:UITableViewStylePlain];
[myLeftView addSubview:tableView];
self.tableView=tableView;
self.tableView.delegate=self;
self.tableView.dataSource=self;
tableView.backgroundColor=[UIColor colorWithRed:26/256.f green:31/256.f blue:36/256.f alpha:0.7];
tableView.separatorStyle=NO;
//data
NSMutableArray *tableDataArray=[[NSMutableArray alloc]init];
NSArray *[email protected][@"首页",@"日常心理学",@"用户推荐日报",@"电影日报",@"不许无聊",@"设计日报",@"大公司日报",@"财经日报",@"互联网安全",@"开始游戏",@"音乐日报",@"动漫日报",@"体育日报"];
self.tableDataArray=tableDataArray;
[self.tableDataArray addObjectsFromArray:dataArray];
return myLeftView;
}
を省略
#pragma mark - テーブルビューデータソース
//この行が正常に動作し、それも
NSLog(@"%@",_tableDataArray[indexPath.row]);
、この行は動作しません数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"%lu",(unsigned long)self.tableDataArray.count);
return self.tableDataArray.count;
}
//の数を返しtableDataArray.countとのtableViewのカウント数を記録しますこのコード。私はdataSourceを追加してデリゲートしました、なぜこれが起こりますか?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"reuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
NSLog(@"%@",_tableDataArray[indexPath.row]);
// cell.textLabel.text=_tableDataArray[indexPath.row];
[email protected]"22";
cell.imageView.image=[UIImage imageNamed:@"Menu_Follow"];
return cell;
}
@end
あなたは何をしようとしていますかreloadData –
あなたは何をしようとしていますか?アーカイブしようとしていることを教えてください。 –
この行を置き換えてみてください 'UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath]; ' –