Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios EXC_以编程方式创建表视图时访问错误_Ios_Uitableview_Exc Bad Access - Fatal编程技术网

Ios EXC_以编程方式创建表视图时访问错误

Ios EXC_以编程方式创建表视图时访问错误,ios,uitableview,exc-bad-access,Ios,Uitableview,Exc Bad Access,我试图以编程方式创建一个视图,其中包含两个视图,一个用于搜索,另一个是一个显示照片的tableview 但我有EXC_BAD_访问错误,代码=2,所有控制器代码如下。我怀疑有一个无限循环,但不明白为什么。 谢谢你的帮助 @接口PhotosViewController() @属性(强,非原子)UITableView*tableView; @结束 @视图控制器的实现 -(无效)viewDidLoad{ [超级视图下载]; //加载视图后执行任何其他设置。 self.title=@“Instagram

我试图以编程方式创建一个视图,其中包含两个视图,一个用于搜索,另一个是一个显示照片的tableview

但我有EXC_BAD_访问错误,代码=2,所有控制器代码如下。我怀疑有一个无限循环,但不明白为什么。 谢谢你的帮助

@接口PhotosViewController()
@属性(强,非原子)UITableView*tableView;
@结束
@视图控制器的实现
-(无效)viewDidLoad{
[超级视图下载];
//加载视图后执行任何其他设置。
self.title=@“Instagram”;
[self.tableView注册表类:[PhotoTableViewCell类]forCellReuseIdentifier:CellIdentifier];
self.tableView.estimatedRowHeight=UITableViewAutomaticDimension;
self.tableView.allowselection=否;
}
-(无效)未收到记忆警告{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
-(void)负荷视图
{
_tableView=[[UITableView alloc]initWithFrame:[[UIScreen mainScreen]applicationFrame]样式:UITableView样式普通];
_tableView.autoresizingMask=UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_tableView.delegate=self;
_tableView.dataSource=self;
[_tableView重载数据];
[self.view addSubview:_tableView];
}
#pragma标记-表视图数据源
-(NSInteger)表格视图中的节数:(UITableView*)表格视图{
返回1;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节{
返回1;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
PhotoTableViewCell*单元格=(PhotoTableViewCell*)[tableView出列重用CellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//配置单元格。。。
[self-configureCell:cell-atIndexPath:indexPath];
返回单元;
}
-(CGFloat)tableView:(UITableView*)表视图行高度索引路径:(NSIndexPath*)索引路径{
//NSLog(@“%f”,self.navigationController.navigationBar.bounds.size.height);
return/*tableView.bounds.size.height-self.navigationController.navigationBar.bounds.size.height-*/40.0;
}
#pragma-mark-Helper方法
-(void)configureCell:(PhotoTableViewCell*)单元格atIndexPath:(NSIndexPath*)indexPath{
//配置光电池
如果(单元格==nil){
cell=[[PhotoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
cell.namelab.text=@“Mister Tester”;
cell.dateLabel.text=@“2小时前”;
}

在loadView中,您不应首先调用[super loadView]或分配self.view


我相信阅读self.view而不阅读self.view会导致无限循环

loadView
中,您不应该首先调用
[super loadView]
。我相信阅读self.view时没有这一点会导致无限循环。另外,在该函数中,您没有将self.view分配给视图,只是使用了它。非常感谢您,self.view=[UIView new]是答案…Fab。如果您愿意接受的话,可以贴出来作为答复。