I don't know what to think...
I set up my main view to contain a UITableView
. (I am using a UIPickerView as well on that view.)
I defined it to conform to the protocols:
UIPickerViewDelegate,
UIPickerViewDataSource,
UITableViewDataSource,
UITableViewDelegate
Announced the two methods in my view's h:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
implemented them in m:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"] autorelease];
cell.textLabel.text = [NSString stringWithFormat:@"Test %d",indexPath];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
I did set the delegate in my viewDidLoad
:
searchTableView = [[UITableView alloc] init];
[searchTableView setFrame:CGRectMake(searchBar.frame.origin.x+10, 50, searchBar.frame.size.width-20, 300)];
searchTableView.delegate=self;
And yet, not numberOfRowsInSection nor cellForRowAtIndexPath are ever called!
What am I doing wrong ?
设置数据源:
[searchTableView setDataSource:self];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.