我剛剛啓動了Xcode objective-c,現在我試圖創建一個帶有textfields的tableview來輸入。我研究過其他堆棧溢出問題,但很多都是在6-8年前,似乎有廣泛的答案和極其複雜的問題。有人可以幫助我瞭解如何在表格視圖中插入文本字段並提供一些建議。謝謝!在UITableview中添加UITextField基本信息
回答
寫代碼的UITableView細胞
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(110, 10, 185, 30)];
textField.clearsOnBeginEditing = NO;
textField.textAlignment = UITextAlignmentRight;
textField.delegate = self;
[aCell.contentView addSubview:txt];
ok現在就試試吧 –
你可以做到這一點,如下所示:
- 拖放到您的視圖
- 拖放一個UITableView拖放一個UITableViewCell成你的桌子。
- 拖放一個UITextField(或任何其他 UI組件,你需要)
我建議你請參見教程,像
1. https://videos.raywenderlich.com/courses/22-table-views-in-ios/lessons/8 2. https://www.appcoda.com/expandable-table-view/
他們有最好的教程與所有步驟,你可以輕鬆地做任何你想要的。
我希望它能幫助你。
謝謝。
非常感謝,將查看教程出來 –
我已經更新了正確的教程鏈接。同樣也適用於appcode鏈接。 –
非常感謝很多 –
試試下面的代碼
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil) {
/*
* Actually create a new cell (with an identifier so that it can be dequeued).
*/
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
/*
* Now that we have a cell we can configure it to display the data corresponding to
* this row/section
*/
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(45, 30, 200, 40)];
tf.textColor = [UIColor colorWithRed:0/256.0 green:84/256.0 blue:129/256.0 alpha:1.0];
tf.font = [UIFont fontWithName:@"Helvetica-Bold" size:25];
tf.backgroundColor=[UIColor whiteColor];
[email protected]"Hello World";
[cell.contentView addSubview:tf];
/* Now that the cell is configured we return it to the table view so that it can display it */
return cell;
}
您可以創建自定義單元格。在其中添加文本字段並通過註冊筆尖或類在表中使用該文本字段。
- 1. 將文本從UITextField添加到NSMutableArray並在UITableView中顯示
- 2. uitableview中的Uitextfield
- 3. 在uitableview的多個UITextField中添加不同類型的驗證
- 4. 如何在UITableview中添加UITextField,UITextView,UILabel和UIButton,如表單iPhone?
- 5. 在freebase中查詢基本信息
- 6. 添加JList以顯示基本的數據庫信息
- 7. UITextField在UITableView中成爲FirstResponder
- 8. iphone,在UITableView中的UITextField
- 9. 在UITableView中的Handeling單uitextfield
- 10. UITextField代表在UITableView
- 11. SSRS顯示基本信息
- 12. .NET基本類型信息?
- 13. 訪問Facebook基本信息
- 14. 在.net中添加作者信息
- 15. 在MATLAB中添加特定點信息
- 16. 如何在元組中添加信息?
- 17. 在openlayers中添加彈出信息?
- 18. 如何動態地添加文本框,並在數據庫中添加信息?
- 19. UITableView內的UITextField
- 20. 在UITableView中添加多列
- 21. 動態添加uitextfield在iphone
- 22. 添加修訂信息
- 23. jQuery Datatable Modal - 添加信息
- 24. Envers添加用戶信息
- 25. 添加信息到按鈕
- 26. 添加信息從parentdatatable到
- 27. 添加信息到datagridview(VB.NET)
- 28. 添加序號信息
- 29. 在UITableViewCell中添加UITableView。 TableView中高度使得基於內容
- 30. 將文本字符串添加到UITextField
只需通過故事板拖放uitextfield到'UITableViewCell'中即可。 – Maddy