如何在 iPhone 的 tableview 的最后一行添加文本字段?
当我按下新按钮时,我需要在表格视图的最后一行添加一个文本字段。
任何人都可以解释一下流程。
提前致谢。
when i press the new button i need to add a textfield on last row of tableview.
can any one explain the flow.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚尝试过这种情况。
像这样创建一个布尔变量
BOOL newButtonPress = NO;
然后使用以下代码
然后将以下代码添加到 cellForRowAtIndexPath 方法中
Just i tried this scenario.
Create a one Boolean variable like this
BOOL newButtonPress = NO;
then fallow the below code
Then add the below code into the cellForRowAtIndexPath method
如果您只想让文本字段出现在表格末尾,为什么不考虑使用 UITableview 的 tableFooterView 属性呢?
在这种情况下,您不必确保在委托方法中返回 UITextField。
如果您使用 InterfaceBuilder 或 XCode 4,您几乎应该能够在 Tableview 中拖放一个新的 UITextField。
If you just want the text field to appear at the end of the table, why not consider using UITableview's tableFooterView property?
In that case you don't have to ensure that you return the UITextField in your delegate methods.
You should nearly be able to drag drop a new UITextField in your Tableview if you are using InterfaceBuilder or XCode 4.
我对 iPhone 编码很陌生,我想分享我的想法。如果这是错误的请忽略。
在
cellForRowAtIndexPath
方法中,您需要设置一个textfield
if(indexPath.row==numberOfRows-1)
条件。在按钮按下方法中,您可以设置
textField.hidden=NO
并在viewdidload
中设置textField.hidden=YES
。I am very new to iphone coding,i want to share my thoughts. If that is wrong please ignore.
In
cellForRowAtIndexPath
method u need to set atextfield
inif(indexPath.row==numberOfRows-1)
condition.In button pressed method u can set
textField.hidden=NO
and inviewdidload
textField.hidden=YES
.