Providing *hint* in text field in ios 7 as edittext field in android

I am creating a feedback form in an ios7 application and want to place few UITextFields which contain hints in the respective UITextField for name, phone number, email address, etc. I am using xcode 5 and ios7 for programming and creating application without use of storyboard.

The hint property is available in android for edit text field, but I am unable to find any such property in UITextField in ios 7.

Answers


Make use of the Placeholder text property.

Here's an example:

UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 10, 100, 50)];
textField.font = [UIFont fontWithName:@"Arial" size:20];
textField.placeholder = @"Your hint here.";

If you are using a storyboard or XIB, this property can be edited there also.

Also, if you want to use custom attributes for the placeholder, you can use the attributedPlaceholder property:

NSAttributedString *attribString = [[NSAttributedString alloc] initWithText:@"Your hint here." attributes:@{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:16.0]}];
textField.attributedPlaceholder = attribString;

Need Your Help

EF 7 (Beta 7) One-to-One Relationship

c# entity-framework entity-framework-core

I've noticed questions that have answered this problem for earlier beta versions of EF 7 (like here), but I haven't seen it solved for Beta 7, so here it goes:

Use AJAX to update page when new row is added to table

php javascript jquery mysql ajax

I am in the process of learning AJAX, as I need it for a current project. I have a feed which I want to update live when a new row is added to a MYSQL table. I've actually done this with node.js, but