开发者

UITableViewCell edit mode like contacts app

I'm currently working on an app where a user has to edit his/her profile. I would like to use the edit mode like in the contacts app. (Labels become Textfields)

Is there an easy way to achieve this? Or do I have to replace the cell.detailTextLabel.text with a uitextfield by myself?

Exampl开发者_高级运维e contacts app editing view: http://content.screencast.com/users/EricMulder/folders/Jing/media/0839c0c9-43df-4283-bcf1-65f49b43696f/00000047.png


For anyone interested, here is some sample code to add an UITextField to your cell:

                cell.textLabel.text = NSLocalizedString(@"nameLabel", @"");
                //add textField
                if(![cell viewWithTag:101]) {
                    UITextField *aliasField = [[UITextField alloc] initWithFrame:CGRectMake(93, 13, 225, 44)];
                    aliasField.text = @"Eric Mulder";
                    aliasField.font = [UIFont boldSystemFontOfSize:15.0f];
                    aliasField.tag = 101;
                    [cell addSubview:aliasField];
                }
                cell.detailTextLabel.text = nil;


ejazz,

Why do you suppose that they are labels? ; )

You can draw custom cell with UITextField in interface builder. Load it from xib. And change textfields editable property in your implementation of setEditing:animated: method of your view controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜