我剛剛啓動了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. 在UITableView中加載本地json信息
- 2. 將文本從UITextField添加到NSMutableArray並在UITableView中顯示
- 3. 在servlet中添加基本的http認證信息
- 4. 在HTML頭中添加文本信息
- 5. html2canvas基本信息
- 6. uitableview中的Uitextfield
- 7. 在uitableview的多個UITextField中添加不同類型的驗證
- 8. 如何在UITableview中添加UITextField,UITextView,UILabel和UIButton,如表單iPhone?
- 9. 在freebase中查詢基本信息
- 10. 如何使用UITextField將信息輸入到UITableView?
- 11. 添加JList以顯示基本的數據庫信息
- 12. 從UITableView獲取UITextField文本
- 13. 在UITextField中添加按鈕
- 14. 在UITableView中的Handeling單uitextfield
- 15. UITextField在UITableView中成爲FirstResponder
- 16. iphone,在UITableView中的UITextField
- 17. UITableView詳細信息
- 18. UITextField代表在UITableView
- 19. 將信息添加到文本文件
- 20. 將鏈接添加到信息文本
- 21. SSRS顯示基本信息
- 22. JCR框架基本信息
- 23. Facebook基本用戶信息
- 24. i18next的基本信息
- 25. jQuery $ .post基本信息
- 26. .NET基本類型信息?
- 27. 訪問Facebook基本信息
- 28. 在linux中爲libudev添加信息
- 29. 在openlayers中添加彈出信息?
- 30. 如何在元組中添加信息?
只需通過故事板拖放uitextfield到'UITableViewCell'中即可。 – Maddy