Welcome, Guest
Username Password: Remember me

How to get a label before and behind a TextField
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: How to get a label before and behind a TextField

How to get a label before and behind a TextField 1 year, 3 months ago #1

Hello Sensible users,

I'm a new STV user. Can you please tell me how I can create a SCTextFieldCell with a label before and behind the TextField ?

thanks for the advice


Frank
  • frank
  • OFFLINE
  • Junior Boarder
  • Posts: 20
  • Karma: 0

Re: How to get a label before and behind a TextField 1 year, 3 months ago #2

Is there a graphic example you could post or point to that illustrates what you want to see?
  • Geoffrey
  • OFFLINE
  • Senior Boarder
  • Posts: 48
  • Karma: 3

Re: How to get a label before and behind a TextField 1 year, 3 months ago #3

sure - see screenshot

I want the text "days" behind the textfield with 30

so the endresult is :

Show targets of 30 days



Frank
Screen_shot_2011_02_07_at_15.png
  • frank
  • OFFLINE
  • Junior Boarder
  • Posts: 20
  • Karma: 0

Re: How to get a label before and behind a TextField 1 year, 3 months ago #4

That's easy to do using placeholder text in the textField. There is a field for that in the IB Inspector if you are using Interface Builder, and STV has parameters you can assign in code for the same thing.

Here's a snippet Tarek posted elsewhere for that:
...
SCPropertyDefinition *propADef = [sampleClassDef propertyDefinitionWithName:@"propA"];
propADef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"placeholder for propA"];
...


So, the placeholder data is not 'behind' the table, but is data within the field in the cell itself, and when the field is selected for editing the placeholder disappears and you get the editing cursor in its place.

What you would have displayed then is a Label that says "Show Targets of" and then the placeholder "(Days)" or the like in the textField (as a default). When the cell is selected for editing the (Days) goes away but no problem there, the point is gotten by the user what type of data to enter. If on redisplay (if there is existing data, for example '30') you could catch the cell before displaying using a delegate method and change "Show Targets of [30]" (what would be displayed) to "Show Targets of [30 Days]" [brackets indicate the textField content].

With a little ingenuity and STV's delegate methods and configurability you can make your interface communicate whatever it needs to.

Search on "Placeholder" in this forum for more examples.
  • Geoffrey
  • OFFLINE
  • Senior Boarder
  • Posts: 48
  • Karma: 3
Last Edit: 1 year, 3 months ago by Geoffrey.

Re: How to get a label before and behind a TextField 1 year, 3 months ago #5

hello Geoffrey,

Thank you for your quick response. Sorry that my English was not clear but your solution is not exactly what I'm looking for.

What I want is a label on the left and on the right side of the TextField, not a placeholder within the textfield.

Do you have a solution for that too ?


thnx
Frank
  • frank
  • OFFLINE
  • Junior Boarder
  • Posts: 20
  • Karma: 0

Re: How to get a label before and behind a TextField 1 year, 3 months ago #6

Check my edit, that gets closer to what you want I think, but you would have to make a custom cell if you need a real extra label item in the part of the cell that has the data field, and yes this can be done. Configuring a custom cell with multiple fields and controls etc. is part of the new 2.0 release but I haven't worked with it enough to give a good example, but here is where Tarek introduced it and we discussed:


www.sensiblecocoa.com/forum/announcement...0-beta-released.html


You would build the cell in IB and reference it in your tabelmodel def.
  • Geoffrey
  • OFFLINE
  • Senior Boarder
  • Posts: 48
  • Karma: 3
Last Edit: 1 year, 3 months ago by Geoffrey.
  • Page:
  • 1
  • 2
Time to create page: 2.31 seconds