UIToolbar reuse like inputAccessoryView - iphone

Some quest!
If i have toolbar in view(bottom) and i want that he will become like input accessoryView for textview. It is possible? Or i must use animations core for this manipulation?

Related

Subclass UIButton or inherit from UIControl?

I have an element that needs to behave like UIButton but it has several (3) text labels visible at once and multiple UIImages in the same bounding box. It's really a view with a bunch of different other UIViews and labels that needs to look and act like a button but with more custom placement of these elements than the standard UIButton.
Is it better to inherit from UIButton to accomplish this or is UIControl the one to inherit from?
When the element is tapped, I do want to mimic all of the highlighting effects (if it's UILabel, show the highlight text color, etc) as well.
As long as it doesn't matter which part of your button content gets tapped to activate it's functions you could compose a UIButton along with all the UILabel, UIImageViews you need.
You could easily inherit from UIView, place all of the above inside and place your transparent UIButton on top of everything to get the events you need (setting yourself as the target for that button and implementing some delegate to notify about selection).

Glossy button (similar to UISegmentedControl) in UITableViewCell

I have a grouped UITableView with a row per section. I would like the same effect as the UISegmentedControl button (glossy/3D-ish/Modern look). What's the best way to do this without tearing down my UITableView methods code?
Thanks
You don't need to tear down the tableView methods code...
Just have to customize your tableViewCells. Here you can seen how it should be done.
You'll need a glossy background Image or draw it yourself in code dynamically (not recommended)
You can customize UIButton and use it in your cells, or you can directly customize cell background view and text label to make it look like a button.
For customizing the background of the cell: Setting background image of custom table view cells
You may also consider using a simple, ready-to-use custom button component. It also provides a custom cell that you can easily use in your tableviews.
Looks like:

Updatable, custom view on a UIToolbar

I want to make a small area to present some information in the middle of a UIToolbar and was wondering what the best way to do this is.
I need to show some text and a graphic, both of which need to be updated (around every 3 seconds) as new information arrives. The graphic is similar to the iPhone signal strength indicator, so it can be either custom drawn or selected from one of 3 graphics (low, medium, high strength).
I'll probably use initWithCustomView: to create a UIBarButtonItem, although I would like the view to be clickable (to allow the user to change the information shown).
What's the best way to make that view? Can I use a NIB, or do I need to do custom drawing in the view? What's the best way to update the buttons? I'm assuming that I'll have to remake the toolbarItems array each time and set it when the information changes. Is there a cleaner way to do this? Thanks.
Using initWithCustomView: sounds like a good way to go. You can create your custom view any way you want: with a NIB, by drawing it, even using images. It can also have its own subviews. It can be any object that inherits from UIView. (So, if you wanted, you could even make it actionable by using a UIButton, a custom UIControl, or a custom UIView with a gesture recognizer attached.)
You shouldn't have to remake toolbarItems (or, for that matter, do anything with it after you've added all your button items) if you just keep a pointer to your custom view UIBarButtonItem. It could be an instance variable. Then, to update the custom view, you could access it as you would any other view. I've never actually tried this, but I can't see any problem with doing it.
You sound like you had it mostly figured out. Hope this is helpful.
I needed the same solution and was hoping for some code examples from you. So I ended up doing it all in IB and the steps are here as follows:
Create UItoolbar in IB with no Items. (A Bar Button Item will be added again once you add the UIView)
Add UIView as subview of UIToolbar
Add UILabels to subview of UIView that is already a subview of the UIToolbar.
Create IBOutlets from UIToolbar, UIView and each UILabel and then you can reference the labels in your app.
I did set the backgrounds to clearColor so the text appears on top of UIToolbar without any box or borders.
And the text updates dynamically which was the desired outcome.
Hope this helps someone as this has been eluding me for a while.

Use the system keyboard without a UITextView or UITextField

I am creating an app with core graphics that needs to take text input and place characters at specific pixel offsets.
Do I have to subclass UITextField or something and re-invent the wheel (redefine it to be a more abstract text entry widget - really I only need the events a UITextField generates) or can I somehow show the keyboard, receive it's events and dismiss it myself!
Thanks!
You could instantiate a UITextField with a frame that makes it invisible (off the "screen" to the left or the top for instance, and make sure the parent view is set to clip child views), and then call [myTextField becomeFirstResponder] to show the keyboard. Make your view controller a UITextFieldDelegate and follow all changes to the text that way, echoing the string using your custom drawing code.

Adding a subview to UITableCellView

I want to add a subview to the UITableCellView class. However, non of the provided views in the class seem to be able to do exactly what I was looking for.
I basically want to add my own background view, filling the whole cell. However, if I replace the backgroundView, the style from the grouped table view layout isn't displayed anymore. If I add a subview to backgroundView, the subview is not shown at all. If I add a subview to the contentView, I can't draw behind the accessory icon.
What am I missing?
Basically you can't change the backgorund of GroupedTable View.
Try using it with PlainTable.
and add the your backgroung image (of size = cellsize) to cellforRowAtIndex method.
You might want to take a look at this article:
"Easy custom UITableView Drawing"
In particular:
First: the UITableView does not itself
draw anything except the background.
To customize the background of a
UITableView, all you need to do is set
its backgroundColor to [UIColor
clearColor] and you can draw your own
background in a view behind the
UITableView.
Simply add the custom view as part of your contentView. Set a unique reuse identifier for that cell, configure it when you create it and from then on simply reset the data components (this is easiest to do if you create a custom cell controller class so that it can track all the parts and use setters/getters for the data).