ios - Adding UITexfield to UITableviewCell causes detailTextLabel to slide "up" -


i'm trying add uitextfield contentview of uitableviewcell. works, , field has focus, detailtextlabel slides 10px. what's deal here? secondary question, there better way create in-line edtiable uitableviewcell?

here's code. i'm trying result of double tap on tableview cell. retrieve actual cell tapped this:

cgpoint swipelocation = [recognizer locationinview:self.tableview]; nsindexpath *swipedindexpath = [self.tableview indexpathforrowatpoint:swipelocation]; uitableviewcell *swipedcell;

then try add textfield this:

swipedcell = [self.tableview cellforrowatindexpath:swipedindexpath]; nsinteger indent = swipedcell.indentationwidth; uitextfield * newtext = [[uitextfield alloc] initwithframe:cgrectmake(indent, swipedcell.contentview.frame.origin.y, swipedcell.contentview.frame.size.width, swipedcell.contentview.frame.size.height)]; newtext.font = swipedcell.textlabel.font; newtext.text = swipedcell.textlabel.text; newtext.textcolor = [uicolor graycolor]; newtext.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; swipedcell.textlabel.text = @""; [swipedcell addsubview:newtext]; [newtext becomefirstresponder];

not entirely unlike yours, except when apply code, both text , detaillabel end in center of cell. ideas?

without out seeing code it's difficult know what's going on. here's code use make uitextfield contentview cell works without issue, helps.

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"taxcell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; cgfloat optionalrightmargin = 10.0; cgfloat optionalbottommargin = 10.0; uitextfield *textfield = [[uitextfield alloc] initwithframe:cgrectmake(275, 10, cell.contentview.frame.size.width - 270 - optionalrightmargin, cell.contentview.frame.size.height - 10 - optionalbottommargin)];   textfield.placeholder = @"placeholder"; textfield.delegate = self; textfield.autoresizingmask =  uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; textfield.clearbuttonmode = uitextfieldviewmodewhileediting;  textfield.text = @"textfield text" cell.textlabel.text = @"textlabel text" cell.detailtextlabel.text = @"detail text"; [cell.contentview addsubview:textfield];  return cell; } 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -