我有一个UIViewController
,我要用来实现的方法UITableViewDataSource
上。 我有这个头, FriendsController.h
:
#import <UIKit/UIKit.h>
@interface FriendsController : UIViewController <UITableViewDataSource>
@end
编辑:现在更新@interface
声明:
@interface FriendsController : UIViewController <UITableViewDataSource, UITableViewDelegate>
实施这一项目, FriendsController.m
:
#import "FriendsController.h"
@implementation FriendsController
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
NSLog(@"CALLED .numberOfRowsInSection()");
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"CALLED cellForRowAtIndexPath()");
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"FriendCell"];
cell.textLabel.text = @"Testing label";
return cell;
}
@end
当运行这给了我一个“ -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x81734d0
”。 任何人都可以看到,如果有什么问题我执行/声明.numberOfRowsInSection()
编辑:我从添加方法上市的技术在这里并运行视图“无关”,它输出以下列表:
[<timestamp etc>] Method no #0: tableView:numberOfRowsInSection:
[<timestamp etc>] Method no #1: tableView:cellForRowAtIndexPath:
[<timestamp etc>] Method no #2: numberOfSectionsInTableView:
[<timestamp etc>] Method no #3: tableView:didSelectRowAtIndexPath:
[<timestamp etc>] Method no #4: viewDidLoad
邮政scriptum:两个@ThisDarkTao和@Pei得到它的权利,如可以在我刚才的问题中可以看出记录的视觉部分, 在这里 。