UIRefreshControl hidden by a customview: how to proceed? - ios

I've a UIViewController which contain an UITableView with a UIRefreshControl as a subview of this tableview.
When there is at least one element in the tableview, everything is fine. I can pull-to-refresh without issue.
However, I created recently a new custom view which mean to be displayed above the tableview when there is no element in it. It look like this:
The issue is: when there is this "no element" custom view displayed, my UIRefreshControl does not work anymore. It's a normal behavior: there is a view above my tableview so gesture controls are not working on the tableview.
So my question is: how can I manage my view so I will be able to pull-to-refresh even if there are this "no element" custom view above my tableview?
Thank you!

First you disable the user interaction of customView. Then may be it will be help you to resolve your problem.

Ok so I did not thougth enought about this question...
I just simply need to add this customview as a subview of my tableview.

Related

UITableView inside a UITableView?

Generally:
Is it OK to add a UITableView as a subview of another UITableView? Or, should I create a UIView and add each UITableView to it?
Specifically:
For a ComposeTableViewController with a typeahead, like in the iPhone's native Mail app, which approach would you recommend and why?
Note: I prefer to construct things 100% programmatically (no Interface Builder).
Subclass UITableViewController.
Then, to show the typeahead results, create and add a resultsTableView as a subview of self.tableView positioned directly underneath the the cell (of self.tableView) with the typeahead text field.
The nice thing about this approach is that resultsTableView scrolls with self.tableView automatically.
But, is it OK to add a UITableView as a subview of another UITableView?
Subclass UIViewController.
Create and add tableView (custom property) as a subview of self.view.
Create and add resultsTableView also as a subview of self.view.
The annoying thing about this approach is that I have to reposition resultsTableView manually anytime self.tableView scrolls.
I think I'd prefer approach 1, but adding a UITableView as a subview of another UITableView just seems smelly to me.
TableViews cannot have subviews. You can try adding a tableview as the view of a TableViewCell, but then you have to ask yourself how it would scroll, if you tried scrolling in the subtableview would it scroll the child tableview or the parent tableview? It is much easier to present multiple tableviews within a view. This can be done easily by setting your custom viewcontroller as the datasource of both tableviews contained within its view and then comparing the tableview pointer that is sent as a parameter of the datasource method to the two tableview pointers that are IVars of your custom view controller.
Hold stuff like this in a container. Create a container view controller which only does typeahead. This container view controller will hold your main table view controller (and its table view) and it will hold the typeahead view controller (and its view).
It will keep the logic needed for the typeahead out of your main table view and as a bonus you might end up with a reusable typeahead container which could be applied to other views.
Yes it is good to go for adding UITableView in as a cell of another UITableView.
I had one issue and posted a question
Multiple Views as subviews
And requirement was like a group of controls with list of other controls. I thought that time that it will be messy if i'm going to add UITableView as a cell of UITableView.
What i found that... Boy !! it's how iOS meant to be. There is no any lag while doing this.
Tested for below functionalities:
Scrolls like a charm
Separate delegates called for each
Reordering of both UITableView cell
Swipe and remove cell
Runtime datasource update for both UITableView and reload both at the same time.
There is no any reason not to add subview UITableView.
You can do it but it is against the principle of MVC. You will be setting the delegate of a view to another view which is wrong.

Static TableViewCells Hidden Above Screen

I had three UIPickerViews in a Static TableView that was working well and decided to delete top most UIPickerView. Now the UIPickerView that at the top of the view is hidden. If I swipe my TableView down, I can see it but cannot select it.
I believe my TableViewController is set up correctly but may be missing something. I tried deleting the TableViewController completely in StoryBoard but this did not correct it.
Has anyone encountered a problem like this? I can post code if necessary.
Thanks!

UISearchBar acting like a UITableView Cell

I have a UISearchBar implemented into my UITableViewController, my problem is when I scroll down in my table view, the search bar acts like a cell and scrolls with the table, therefore disappearing. Is there a war to programmatically fix this?
I know there are similar questions on SO with this issue and I have exhausted all the resources provided in those posts.
Thanks
Sure, don't use an UITableViewController but use a normal UIViewController with UITableView and UISearchBar inside.
When you use an UITableViewController, its UIView is directly the UITableView. So every control and subview go in the tableView. For this reason you need to change strategy and use the way above.

How to add centered UIActivityIndicator for UICollectionView when using UICollectionViewController?

I'v never used UITableViewControllers or UICollectionViewControllers, because you can have the same functionality by using UIViewController with its root UIView, then adding UITableView in xib or storyboard and assigning its delegate and datasource. And I also was able to put activity indicator inside the center of root UIView.
Now the things get a little bit complicated when using UICollectionViewController where its root view is UICollectionView. I need to update some code of other guys and they put activity indicator inside UICollectionView (in storyboard). The problem is this activity indicator gets hidden when cells are reused because activity indicator view is the most bottom one. I was unable to change visibility priority storyboard and also this code in view didLoad is not working:
[self.itemsCollectionView bringSubviewToFront:self.activityIndicator];
Because labels, images and etc. views of collection view cell are placed later, during collectionView:cellForItemAtIndexPath:. I could try to call bringSubviewToFront: in collectionView:cellForItemAtIndexPath: but that would be a wrong decision. Any ideas how to achieve this when using UITableViewControllers or UICollectionViewControllers?
IMHO the only reason to use UITableViewControllers or UICollectionViewControllers is because static cells are not shown storyboards when designing layout.
UPDATE It appears iOS wraps UICollectionView inside UICollectionViewControllerWrapperView. Tried to add activity to this wrapper view in viewWillAppear:
[self.itemsCollectionView.superview addSubview:self.activityIndicator];
But with no luck - activity indicator is still is below the cells.
I'v ended in refactoring existing UICollectionViewController in storyboards: I'v opened storyboard xml file with TextEdit, searched for the screen and changed its type from collectionViewController to viewController because was unable to find another way how to change the type of controller, though I hope there will appear some more elegant way for that in the nearest future. Then, I'v wrapped collectionView inside root view and placed activityIndicator inside this view. It's proven classical approach that works like a charm.

UITableViewController does not automatically resizes and repositions its table view when there is in-line editing of text fields

UPDATE (SOLVED ALREADY) :)
I tried to recreate my scene from scratch. And I found out that if the Class of the table view controller is "UITableViewController", the repositioning of view when keyboard appears happens properly. But when I set the Class of the table view controller to my custom class, the repositioning doesn't happen. Why is this so? Given that my custom class is a subclass of UITableViewController and nowhere in my implementation did I implement any data source and data delegate since I am using static cells?
I forgot to add the delegate in my interface declaration. Now it's working already.
#interface CustomClass : UITableViewController <UITableViewDelegate>
I have a UITableViewController where the tableview content is static cells and style is plain. I added 7 table view cells. In each cell, I added a text field.
When I click on a table view cell, the keyboard shows but the table view did not reposition; thus hiding the table view cell that I selected.
I have solved this before but I was using a view controller then which I embedded inside a scrollview. But seeing from documentation, UITableViewController, which has a scrollview by default, is supposed to automatically resize and reposition it's table view.
I am working on XCode 5 and using iOS 7 latest version.
You can change the offset (y) of the tableView whenever textField's action is didBeginEditing.
If you need any more help let me know ;D
It should automatically change its size, but not necessarily adjust its position/offset.
Are you sure the table view still covers the entire screen, even below the keyboard?
You can check this by scrolling and looking at the scrollbars.
If you want to adjust the content offset, do so in the callback when the user begins editing the text field.
Eliminate the code that sets the content offset of the table view.
The table cell for text field with the first responder status should automatically scroll above the keyboard. You shouldn't have to write a lick of code for this.
If you are using static cells, make sure that your table view controller does not implement the table view data source methods. Also, the view controller that you dragged onto the IB canvas must be a UITableViewController; it can't be a UIViewController that contains a UITableView dragged from the objects library.
After thorough checking, I realised, my custom class only subclass UITableViewController without adding the delegate :(
below solves the problem... at last! :)
#interface CustomClass : UITableViewController <UITableViewDelegate>

Resources