teo*_*teo 6 iphone uitableview uitextview universal ipad
我在tableView单元格中使用UITextView来编辑文本.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITextField *textName = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 270, 24)];
[cell addSubview:textName];
[textName release];
}
Run Code Online (Sandbox Code Playgroud)
这有效,但在iPad上运行时则不正确.
我试图使用cell.contentView.frame.size.width来确定单元格的宽度
但对于iPhone和iPad,这总是会返回320.0
在横向模式下iPad上也不应该更大的单元格宽度?
张志贤
理想情况下,您可以创建自定义UITableViewCell并调整layoutSubviews.
如果您要在 中添加控件tableView:cellForRowAtIndexPath:,那么您可以从 tableView 本身获取宽度:
UITextField *textName = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width-50, 24)];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3964 次 |
| 最近记录: |