我想添加一个pickerView到我的表格视图中的一行,但做完这些之后,我看到的只是单元格内的一个黑色矩形。添加一个UIPickerView到UITableView单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
pickerView = [[[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 0.0, 200, 300)] autorelease];
[cell.contentView addSubview:pickerView];
}
}
我真的没有线索如何解决这个问题。 任何人都可以帮助我吗?
单元格是否保持pickerView的正确大小? – 2011-03-16 11:39:34
您是否需要设置选取器视图的某些属性,以便知道要显示的内容?尝试用UIDatePicker子类交换UIPickerView,以便知道它确实获得了一些内容。 – 2011-03-16 11:40:27
非常感谢。 UIDatePicker的作品。 – steve 2011-03-16 12:43:16