Material TextView via Storyboard? - swift

Is there a way to implement the material TextView via the storyboard? The example only shows via programmatically. Please help?

The answer is actually quite simple, and I just discovered it myself while attempting to do what you asked. All you need to do is go to the identity inspector of whatever object you want to use as a material object, then in the "class" field, put the ID of whatever material class you're using (i.e. "RaisedButton"), and you're all set! Hope this helps!

The tricky part about using a TextView in storyboards with the Material Text class that does pattern detection is the instantiation part. Storyboards take care of the initialization for you, which makes it difficult to update the textContainer layer, as it needs to be passed to the TextView when initialized. I am looking into this to see if there is a solution.

If you look at the source of TextField, you will see that it is a subclass of UITextField. This means that you can just change the class of a UITextField object that you drop onto your Storyboard, and then do any other configuration in code.

Related

How do I add functionality to a UI made in storyboard?

I have made a pretty little UI on storyboard but I'm quite new to XCode and Objective C (coming over from Java) and I'm having some trouble adding functionality. I know that I should make a subclass of UITableViewController (storeTableViewController) and set the class of the storyboard controller to that. The problem is that when I do that all my hard work in the storyboard is erased, and I can see where the code is conflicting with the showing of my UI (for instance, the tableView:numberOfRowsInSection returns 0 always), and I think that with enough time and patience I could program the UI, but is there any way that I can use all this work that I've done on the storyboard and still be able to add functionality? I want to set a text box at the top to be the first responder as well as be able to change an image and labels on command programmatically.
You should probably use IBOutlets. Connect the StoryBoard UI Object to IBOutlets and you can modify the properties of the UI objects from the code
You can declare IBOutlet link this
IBOutlet type variableName
Check this tutorial video which will help you a lot.
Video Link
I use the storyboard as a canvas. I plug in the outlets that I want and all the little details and then I go around and built the classes. That being said, you need to declare a urtext field outlet (depending to what you want it to do) then add the delegates necessary and allow it to perform on selector. Then you can declare the function. Linking it in storyboard is easy by control and drag.as far the image you can use an uiimage and declare its function and how it changes depending to what the changes are the code varies. My suggestion is to take screen shot of your storyboard and post it with your question so I/ we can help you with the code. But as far as your question goes I hope this answer satisfies you. Happy coding.:)

Custom Look And Feel of a text field in iOS

I'm a beginner with Objective-C and have a question regarding creating a custom look and feel text box. I want to be able to create a text box area that has, for example a header with a label and different background color etc. where the text input appears. How does one go about doing such a thing in Objective-C? Is it a matter of just creating a custom class that has a UILabel with specific coordinates on top of the UITextBox? Let me know if someone can point me in the right direction. Thanks.
One option is to create a custom view that contains a UITextField and UILabel as sub-views. After that, the view can be re-used.
I highly recommend reading the View Programming Guide # Apple: http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/ViewPG_iPhoneOS/Introduction/Introduction.html
A related post on creating an aggregate custom view: .Net UserControl XCode equivalent
Here's one tutorial on creating a custom view:
http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view
You can also look at how other custom controls are built. Many of the controls at cocoacontrols.com are open sourced: http://www.cocoacontrols.com/
Use layer property of text field like
#property (nonatomic,weak)IBOutlet UITextfield *email;
so in implementation file or view did load method
self.email.layer.backgroundColor = [uicolor orangeColor];

iOS Creating a list of tags

I'm currently trying to implement a feature in my app that shows tags for a post. I want it to work very similar to that of tags here on StackOverflow, in that they have a colored background.
Another example, are the Inline Labels here.
I'm just not quite sure on how to get it implemented. My first guess would to create an array of UILabels... Any suggestions?
Figure out what you want the tags to look like. If you can achieve that appearance with existing components like labels or tokens, then great, problem solved. If not, creating your own UIView subclass that draws a background and bit of text is pretty simple -- you wouldn't need to write much more code than a custom -drawRect: method, and even that should be easy. For example, if you wanted something that looks like the Twitter-ish inline labels, you could start with a resizable image and then draw your text on top.
Don't be afraid to create your own view classes... it's fun!
You probably need to write two classes.
The first (let's call it HorizontalLayoutView) will extend UIView. It will serve as the container view to hold all of the tags. It would override the layoutSubviews method to arrange the subviews by setting their frames. Create one instance of this and add it as a subview to your existing view.
The other (let's call that TagView) will also extend UIView, or perhaps UILabel. Instances of this class will represent each tag. Create one instance for each tag and add it as a subview to your horizontalLayoutView instance. In the initWithFrame: method, you would customize the tag to look the way you want. You can also override the drawRect: method to further customize its look.
If you are adding the tags dynamically after the view is already displayed, you may need to call setNeedsLayout on the horizontalLayoutView instance to get it to adjust properly.
Hope this will get you started in the right direction.

Focus and zoom in on a UITextField when touched?

How in the world does one get the iPhone view to zoom in on a focused UITextField? I need to tap on a text field that I want to edit, and my view should zoom in to the tapped text field and pull up the keyboard (which it already does), similar to how many Internet text fields gain focus on the iPhone. Is this some type of overlay?
I've been looking everywhere for this solution but maybe I've just got the wrong terminology. Thank you in advance.
Could be a duplicate of this StackOverflow question.
In essence, there are a number of ways, but you have to program this effect manually. A textfield is already an overlay. You can either move it, or scroll the containing view.
Please follow the following steps.
Implement the delegate method for all textfield.connect the outlet of textfield in interface builder basically it's setting the delegate property.then in delegate property you can defined the method whatever you want to implement or wanted to do functionality.
Thanks

Can you mix custom-view and non-custom view components in a single UIPickerView?

I have a multi-component UIPickerView in my application. Two components are plain and completely served by the pickerView:titleForRow:forComponent: method. My third component however requires a custom view via the pickerView:viewForRow:forComponent:reusingView: method. I don't see any way in the documentation to have a "partially customized" UIPickerView where some components use ...titleForRow... and some use ...viewForRow.... Is this possible? If so, how does one do that?
You've got to go all or nothing. The plain, boring default views are pretty much just a UILabel. You should be able to easily recreate this view.