Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Iphone 设备上神秘的tableView未在代码中保留_Iphone_Objective C_Ios - Fatal编程技术网

Iphone 设备上神秘的tableView未在代码中保留

Iphone 设备上神秘的tableView未在代码中保留,iphone,objective-c,ios,Iphone,Objective C,Ios,我的RootViewController有两个问题,其定义如下: @接口RootViewController:UIViewController 注意:我在RootViewController.m中声明了UITableViewDelegate中的以下方法,但它们被注释了。首先是UITableViewController,但后来我将其更改为UIViewController - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableVie

我的RootViewController有两个问题,其定义如下:

@接口RootViewController:UIViewController

注意:我在RootViewController.m中声明了UITableViewDelegate中的以下方法,但它们被注释了。首先是UITableViewController,但后来我将其更改为UIViewController

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
如何唤醒我的应用程序:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    RootViewController *rootVC = [[RootViewController alloc] init];
    navigationController = [[UINavigationController alloc] initWithRootViewController:rootVC];
    navigationController.navigationBarHidden = YES;

    [rootVC release];

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}
注释结束

当我尝试构建应用程序时,他崩溃了,出现以下错误

2012-06-13 10:34:23.595 Astrobox[540:707]-[RootViewController tableView:numberOfRowsInSection:]:发送到实例0x151820的选择器无法识别

2012-06-13 10:34:23.609 Astrobox[540:707]***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[RootViewController tableView:numberOfRowsInSection:::]:未识别的选择器发送到实例0x151820'

如果我取消对UITableViewDelegate中的方法的注释,它在iOS 5.1.1 92206设备上运行,但我的RootViewController在屏幕上显示为UITableViewController-自上而下的分隔符,并且由于启用了tableView bounce的性质,我可以使用以下代码轻松修复我的问题,但我不认为这是一个优雅的解决方案

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.bounces = NO;

不要将UITableViewController更改为UIViewController..,然后写入

RootViewController *rootVC = [[RootViewController alloc] initwithnibname:@"YourXib/Nib name"];
而不是

RootViewController *rootVC = [[RootViewController alloc] init];

这应该可以解决您的问题。还要检查tableview的委托和数据源。

检查Rootviewcontroller的nib文件。它可能已连接到tableview控制器。

首先,请不要设置table view委托和数据源,并检查您的视图是否正确加载。之后,在视图中设置以下代码并加载

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
tableView.delegate = self;
tableView.datasource = self;
and implement the < UITableViewDelegate , UITableViewDataSource > in your .h file.
and implement all the 4 methods what ever you have mentioned above and don't call it explicitly.
these are the delegate method they will call itself. 

你能显示RootViewController映像xib吗?你为什么要使用[[RootViewController alloc]init]use initwithnibname我没有使用xib/nib按RootViewController进行构建