UIButton not showing on simulator when view's class is TPKeyboardAvoidingScrollView - iphone

I have this weird problem where the buttons on the simulator or my iPhone are not showing when the class of the view's set to TPKeyboardAvoidingScrollView.
Here's a screenshot:
When the view's class is set to UIView (default) it works properly.

See this post for instructions.
For non-UITableViewControllers, use it as-is by dropping the TPKeyboardAvoidingScrollView source files into your project, popping a UIScrollView into your view controller’s xib, setting the class to TPKeyboardAvoidingScrollView, and putting all your controls within that scroll view.
To use it with UITableViewController, pop the TPKeyboardAvoidingTableView source files in, and just make your UITableView a TPKeyboardAvoidingTableView in the xib — everything should be taken care of.
Are you using it with or without a UITableViewController? Make sure you've embedded the button in your UIScrollView. The site linked above also has a sample project you could reference for more help.

Related

Scene Dock in Apple's Date Cell Example?

I am looking at Apple's Date Cell (Date Cell Link) example project and I have a question about the Scene Dock in MyTableViewController. How come there are items extra items in the scene (Like Picker and Done) that are next to First Responder, Exit, and My Table View Controller? How can this be done? Also, how is this helpful?
This image shows the Scene Dock that I am referring to. Don't mind the titles, I renamed the project.
This image shows the Scene Outline for MyTableViewController, where the Picker and Done Button are shown next to the My Table View Controller, First Responder, and Exit and not within My Table View Controller.
This image shows an expanded outline for My Table View Controller where the Picker object is found also. But not Done Button is nowhere to be found inside My Table View Controller.
This image shows the code to connect to Picker and Done Button There is nothing special to this.
When I delete UIDatePicker in the scene of the controller (not in the cell), the inline DatePicker still works.
I think this sample is meant to support iOS 6.1 or earlier, to reveal the UIDatePicker as an external slide-in view, so it needs to be in the controller for IBOutlet connection.
Hope this will help.
Normally, the MyTableViewController should not be of type UITableViewController but its superclass UIViewController. This is normally necessary because UITableViewController has by definition its main view property set to the table view. It is then difficult to place other views into this view.
With a UIViewController, however, you can add any number of views. This is necessary in this case to accommodate the button and picker. The table view controller functionality can still be achieved by manually adding the UITableViewDataSource and UITableViewDelegate protocols and overriding the appropriate methods.
However, Apple here shows that it is possible by placing the other views on the same level as the main view, the table view. This is admittedly quite confusing. I usually prefer adding non-standard views as subviews to the view of a plain UIViewController.
You can drag things like picker views from the library to the scene dock to add them there.
As to the utility of doing this, I have no idea what that would be.
In this case I think that the picker and done button are left over from the writers of the code experimenting with ideas and forgetting to delete them. To verify that just delete the picker view and done button and see if everything still works.

Can't create outlet using Interface Builder - Lock symbol shown

I'm trying to create outlets using the Interface Builder, however when drag the UILabel from the IB to my controller's .h file the big lock symbol flashes for a few seconds and it doesn't actually create the bind between the UILabel and the outlet (although the code is generated). I also noticed an empty circle is created by this new definition. When it worked, a filled in circle was created on the side).
I've checked the UILabel and all parent views and have checked that their "Lock" property is set to "Inherit (Nothing)" (and have even set them all to "Nothing").
In the IB the UILabel doesn't show the "x" that appear when a UILabel is locked either.
So I have no idea if I'm missing to unlock something, or what I'm doing wrong to be able to create this outlet.
I don't know if this is relevant, but I'm using a custom view controller, and I'm using this same view controller subclass for 2 different view controllers in the same storyboard. I had no problems creating outlets this way for the first view controller.
Tryed reopening XCode (using 4.4.1) with no luck.
Any help is appreciated!
So are you dragging both UILabels from each View Controller into the same file? I don't think that this is possible, on the second view controller, try to Ctrl drag to the file owner within the IB view, that is, assuming that both views are connected to the same instance.
Also, in your identity tab in storyboard, under Localization Locked, make sure your storyboard locked setting is set to default as mentioned in https://stackoverflow.com/a/11169636/720175
I tried adding a totally new scene and would also get the lock symbol. So it wasn't only the scenes, but the whole storyboard. So a quick search on SO lead me to the answer:
https://stackoverflow.com/a/11169636/720175

setNeedsDisplay works on iPhone but not on iPad

The view in question was created in IB on the root view and wired to a class method in the rootViewController. In the view's class method I am overriding drawRect to draw it's content. I am calling setNeedsDisplay on the view from the rootViewController after the user changes some parameters.
On the iPhone this works fine. On the iPad, however, drawRect in the class method does not get called.
I suspect that the reason for this has to do with the drawing cycle. On the iPhone the view used by the user to change the parameters is pushed onto the screen over the view in question. On the iPad this view is added to the root view above, not over, the view in question. So when the view used to change the parameters is closed, unlike on the iPhone, a drawing cycle is not generated and so the invalidated view is not updated.
I'm stuck. Any help would be appreciaetd.
Found the problem...
I discovered that in the xib being used by the root view controller for the iPad, the wiring for the UIView object in question was some how corrupted. When I hovered over the bullet of it's iIBOutlet variable in the .h file an UISegmentedControl elsewhere in the xib would be selected instead of the intended UIView. Right-Clicking the UISegmentedControl did not show that the link existed. The only way I was able to get it fixed was to remove all the wiring from both objects and rewire them properly. Calling setNeedsDisplay now works. as expected, on the iPad just like it does on the iPhone.

iPhone make toolbar visible in UITableView

I have a UITableView has a subview of a UIView and I've added a toolbar on top of the UITableView so it should look like this:
However when I actually run it, it looks like this:
So for some reason the UIToolBar isn't showing up. I really don't know why, is anybody able to figure this one out? Thanks in advance.
EDIT: I've changed the simulated metrics like suggested and it still does not show up:
EDIT2: Here is a list of objects as requested by Raixer.
Alright. I have a similar setup in my app so I will show you what I did.
I setup a tab bar controller with navigation controllers in each tab (this gives me the navigation bar automatically that is why I use it). If you notice the View on the first tab is being loaded from another nib (that is what I am assuming you are doing). I did this by changing the view's class to my own view controller and then setting the name of the NIB file to load in the Inspector like this:
(source: minus.com)
Then in my other nib file I only have this:
I hope this helps.
That's because you configured your nib file without counting with the height of the Tab bar.
The toolbar's height is 49 pixels. So when the view appears all your elements are moved 49 pixels up.
You should got to IB, open your View, go to Attributes Inspector, and in simulated metrics select Tab bar for Bottom Bar.
I doubt you will succeed with this approch. UITableViewController is very picky about adding subviews to its UITableView. However, you can have your UITableView handled by a standard UIViewController (just let IB point to a custom class inheritng from UIViewController). Add the table view to the controller's view as a subview and add the toolbar to the outer view.
Then you should be able to add subviews. UITableViewController gives you some convinience and functionality. If you can live without, UIViewController is no disadvantage. If you can't, you'll have to implement it yourself.
Another alternative to get the toolbar: put your table into a UINavigationController. That one comes with a toolbar (on top).

Subviews disappearing from UIViewController

I have application with multiple UIViewControllers using navigation controller. UIViewController contains tableView, searchbar (that I can show/hide) and toolbar. All of this is added as subviews to its view. All this subviews are created after UIViewController is initialized and their content depend on UIVievController's content.
It works fine expect one problem. When I play with my app a little, move back and forth, open some modal views etc sometimes after navigating back to my root VC all it's subviews dissapear and all I get is white screen.
I double checked all my code and I can't find source of problem (I certainly don't remove them myself). I wasn't able to find exact patern how to reproduce this, it seems random. Any idea why iphone would remove my subviews from VC? I would post some code, but I don't want to put it all here and I am not sure which part is important, so if you wish to see some, let me know
Add your views in loadView or viewDidLoad: when viewDidUnload is called, the view is released, so they need to be created again when the view is shown again.