xcode 将 UIPickerView 添加到 UITableView 单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5324645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding a UIPickerView to a UITableView cell
提问by steve
I am trying to add a pickerView to a row in my table view, but after doing this, all I see is a black rectangle inside the cell.
我正在尝试将一个 pickerView 添加到我的表视图中的一行,但是在这样做之后,我看到的只是单元格内的一个黑色矩形。
- (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];
}
}
I really don't have a clue how to solve this. Can anyone help me, please?
我真的不知道如何解决这个问题。任何人都可以帮助我吗?
回答by Cannon
May be this can help: DateCell with TableViewController
可能这会有所帮助: DateCell with TableViewController