Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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/8/xcode/7.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
Objective c 在表视图中填充数据的问题_Objective C_Xcode_Uitableview - Fatal编程技术网

Objective c 在表视图中填充数据的问题

Objective c 在表视图中填充数据的问题,objective-c,xcode,uitableview,Objective C,Xcode,Uitableview,我真的需要在表视图中填充数据方面的帮助,我的表视图位于导航栏中,导航栏位于选项卡栏中。经过数小时的尝试,在我的导航栏中添加了至少5个数据,但它始终无法填充我的导航栏。这是我一直在使用的代码,应该是正确的代码:(此代码是在-(void)dealloc之前编写的: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the

我真的需要在表视图中填充数据方面的帮助,我的表视图位于导航栏中,导航栏位于选项卡栏中。经过数小时的尝试,在我的导航栏中添加了至少5个数据,但它始终无法填充我的导航栏。这是我一直在使用的代码,应该是正确的代码:(此代码是在
-(void)dealloc
之前编写的:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
           return 1;
    }
    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
           return 5;
    }
    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

           static NSString *CellIdentifier = @"Cell";

           UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
           if (cell == nil) {
               cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
           }

           // Configure the cell.
           cell.textLabel.text = @"Some value";
           return cell;
     }
此外,我尝试将数据源和代理出口链接到文件所有者,但当我运行应用程序时,当我单击我的表视图应该显示我的5个数据的选项卡栏项目时,它停止并崩溃了我的应用程序。当我断开数据源和代理与文件所有者的连接并再次运行应用程序时,Na中的表视图为空没有数据填充的活力条,只有空白

所以我不知道这里还有什么问题,要么我必须再次链接数据源并委派,这将导致应用程序再次崩溃,要么有人认为我的代码不正确,要么我在导航栏中插入表视图并将导航栏插入选项卡栏时有问题


任何人请帮助我,谢谢

请确保您将文件所有者的身份设置为
UITableViewController
的子类,该子类包含您在上面发布的代码。您可以通过在文档窗口中选择文件所有者并使用“身份”选项卡(第四个选项卡)来查看身份在Inspector面板中。

在.h文件中声明
UITableView*myTableView

属性为
@property(非原子,保留)ibuitableview*myTableView

最后合成.m文件中的变量

现在只构建项目并转到IB。您将能够在文件所有者属性检查器中看到IBOutlet。将其连接到从库中拖动的表,然后连接数据源并将其委托给所有者。保存并退出接口生成器

现在构建并运行该项目,ur应该可以正常工作


希望这能起作用!!

上面的代码很好,如果你想让tableview可用,你需要为它声明数据源和委托,所以让它们保持连接,并通过在代码中设置断点来确定崩溃发生的确切位置。嘿,谢谢你的帮助,但显然它不起作用。上面写着:文件的“委托”出口所有者“已连接到”(项目名称)应用程序委派”,但UITableViewController上不再定义“委派”。您有什么可以帮助我的步骤吗?您在谈论哪个nib文件?文件所有者的类别是什么?