【发布时间】:2014-03-01 23:07:48
【问题描述】:
我从 github 下载了 UIPopOverListView,并粘贴到我的工作区,然后当单击按钮时,会出现 popoverlistview,但调用了委托和数据源方法但无法正常工作,
当我的按钮被点击时
-(void) effectsButtonClicked
{
effectsPopView = [[UIPopoverListView alloc] initWithFrame:CGRectMake(10,150,300,200 )];
effectsPopView.delegate=self;
effectsPopView.datasource=self;
effectsPopView.listView.scrollEnabled = FALSE;
[effectsPopView setTitle:@"Effects"];
[effectsPopView show];
}
那么我的数据源和委托是
#pragma mark - UIPopOverListView DataSource
- (NSInteger)popoverListView:(UIPopoverListView *)popoverListView
numberOfRowsInSection:(NSInteger)section
{
return 5;
}
- (UITableViewCell *)popoverListView:(UIPopoverListView *)popoverListView
cellForIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"cell";
UITableViewCell * effectsCell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identifier];
effectsArray=[NSArray arrayWithObjects:@"Black and White",@"Sepia",@"Hue",@"Snow",@"Normal", nil];
effectsCell.textLabel.text=[effectsArray objectAtIndex:indexPath.row];
effectsCell.textLabel.textColor=[UIColor redColor];
NSLog(@"%@",effectsArray);
return effectsCell;
}
#pragma mark- UIPopoverList Delegates
- (void)popoverListView:(UIPopoverListView *)popoverListView
didSelectIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"ROw selected");
}
屏幕截图是
谁能解释一下,为什么数据源和委托不工作
【问题讨论】:
标签: ios objective-c delegates datasource