How can I connect uitextview with GCPlaceholderTextView on storyboard? - ios

I want to use GCPlaceholderTextView
.
When I make IBOutlet UIPlaceHolderTextView model, I can't connect uitextview on storyboard. I have an error -
[UITextView setPlaceholder:]: unrecognized selector sent to instance.
How can I connect uitextview with GCPlaceholderTextView? Does anyone know?

You need to redeclare the class of your UITextView in your Storyboard and put GCPlaceholderTextView.
Otherwise the object initialized is a UITextView and not a GCPlaceholderTextView like you want. So it doesn't have the method setPlaceholder:
Like this :

Related

Custom UILabel not loading from xib

I have a CustomLabel view which is a sub-class of UILabel it self.
Is there any possibility to set properties from Xcode Interface builder for this custom view. I have tried different things specified in this link:
Reuse a uiview xib in storyboard
But nothing is working for me. Will this kind of thing work ?
Sorry, i think its not possible. if you want like this, first we need to add UILabel in interface builder and take outlet connection then we can set properties.
example: self.myLabel.text="hi welcome"

Objective-C: Diagnosing unrecognized selector error

I am using htautomcomplete to add autocompletion to a textfield and getting the error below.
As far as I know I have made the field in question an HTautomplete field but it is saying that it is trying to send the message to an UITextField. Could this be error or what else could cause this? Thanks for any ideas.
[UITextField setAutocompleteType:]: unrecognized selector sent to instance 0x17eea9a0
(lldb)
//code creating property
#property (unsafe_unretained, nonatomic) IBOutlet HTAutocompleteTextField *titleField;
Since this is an IBOutlet, it's most likely that you didn't set the class of your UITextField in the .xib file to be an HTAutocompleteTextField.
You can do so by selecting the object in your .xib file, then going to the Identity Inspector and setting the class under Custom Class.

Can't change view from WatchKit controller

I added a bunch of WKInterfaceLabels to the storyboard, added them as IBOutlets in InterfaceController.h, and used the SetText method to set some text on them. However, I get no change on the view. The console gives the message "Unknown property in Interface description" for each label. How do I fix this?
In InterfaceController.h, I define the label as follows:
IBOutlet WKInterfaceLabel *hdate;
In InterfaceController.m, I set it's text as follows:
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
[hdate setText:#"blah"];}
Since the correct answer is in the comments of the question, I will just post it here again:
You can't create the IBOutlet in the .h file with just
IBOutlet WKInterfaceLabel *hdate
in brackets, I have to set them as properties.
(Credits to user3261697)
Change
IBOutlet
To
#IBOutlet
Or reconnect the label to the view.
In my case, it ran successfully.

Can't get UITextField variable

I'm trying to change the color of some placeholder text, of a UITextField, but i having problems reaching the text field. I've created a property with Referencing Outlets, like this:
#property (retain, nonatomic) IBOutlet UITextField *usernameField;
But can't reach it with either usernameField or _usernameField. What am i missing?
If you have a property, do NOT synthesize it. That just complicates things, and is no longer needed in Objective C 2.0.
Don't use _usernameField. That bypasses the property getter/setter and accesses the iVar directly.
Use self.usernameField instead. Until you understand the difference, use the property except in the code of a custom getter/setter or dealloc method.
first you should use self.usernameField and second just make sure you assigned the outlet to the UITextField you need to access it in the Interface Builder.
You can check it. Have you connected the outlet of the textfield in the xib file?

Change content in UITextView

Quite a simple one I assume but searching has failed me.
I have a UITextView I set up in a Storyboard with some dummy text. Dynamically I would like to change the content of this, but I don't know how. Searching for this seems to only returns results in which the UITextView has been created programmatically as opposed to via a drag and drop on the Storyboard, hence they have direct access to a variable representing it.
Add an outlet to UITextView then changed it dynamically!
Like this:
#property (weak, nonatomic) IBOutlet UITextView *yourText;
self.yourText.text = // ANY TEXT HERE

Resources