gpt4 book ai didi

ios - 使用 UITableView 时 tableView :numberOfRowsInSection . ..NSInvalidArgumentException

转载 作者:行者123 更新时间:2023-11-29 04:31:17 25 4
gpt4 key购买 nike

我有这个标题:

@interface MyBusinessesController : UIViewController

@property (weak, nonatomic) IBOutlet UITableView *businessList;

@property (weak, nonatomic) IBOutlet UILabel *loadingLabel;

@end

我的 .m 文件中有这个:

#import "MyBusinessesController.h"

@interface MyBusinessesController ()

@end

@implementation MyBusinessesController

@synthesize businessList;
@synthesize loadingLabel;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

NSLog(@"HIDING 1");
// HIDE THE LIST UNTIL IT LOADS
self.businessList.hidden=TRUE;
NSLog(@"HIDING 2");
}

- (void)viewDidUnload
{
[self setLoadingLabel:nil];
[self setBusinessList:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

当这个 Controller 运行时,两条 NSLOG 行都会执行,然后异常就会发生。

这是一个异常(exception):

-[MyBusinessesController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6a8f330
2012-07-29 21:31:38.355 BusinessPlan[3973:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyBusinessesController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6a8f330'
*** First throw call stack:
(0x13d5022 0x1566cd6 0x13d6cbd 0x133bed0 0x133bcb2 0x1fd06b 0x1ff862 0xad66d 0xad167 0xb0134 0xb4623 0x5dd42 0x13d6e42 0x1d8d679 0x1d97579 0x1d1c4f7 0x1d1e3f6 0x1d1dad0 0x13a999e 0x1340640 0x130c4c6 0x130bd84 0x130bc9b 0x12be7d8 0x12be88a 0x1f626 0x1bfd 0x1b65)

有人可以帮助我理解这里出了什么问题吗?

谢谢!

最佳答案

您可能已在界面生成器中将 MyBussinessViewController 设置为数据源,但没有在其中设置数据源方法。您可以通过右键单击界面生成器中的表格 View 并查看数据源字段连接到的内容来进行检查。

供您引用:

tableView:numberOfRowsInSection:
numberOfSectionsInTableView:
tableView:cellForRowAtIndexPath:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html

快乐编码。

关于ios - 使用 UITableView 时 tableView :numberOfRowsInSection . ..NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11714533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com