Table View is taking interaction when a view of same bounds is added above that in OS X - ios

My app contains a Table View which is scrolling and taking events properly. But after that I have to show a custom pop up to screen for that I have added a full view over the Table View. But after adding the view over Table View, Table view is still scrolling and taking events.
Please help if anyone have knowledge about that...
Thanks

The best way to achieve this is to add a blur view into your nib file first. This is better approach as the user is made aware of the current enabled object.
Once you add the blur view over the tableView you are showing, add your custom pop-over. This would maintain a clear demarcation between the two views and you would be able to achieve the functionality you want as the touches won't flow to your tableView.

Follow below steps may work:
Add overlay view on screen to show data on top of table view
make TableView Disbaled as soon as u add view on it.

Related

How to make UITableView header to show only when dragging down table view

I have an UILabel that shows me the current date added to the table view header. When the app is running you can see the header right from the start.
What I am after is when the app starts to not see the header, only when you try to drag the table view down, to reveal the label. And when releasing the header should be hidden again.
I think Snapchat uses this technique in their Stories screen.
Any ideas how can this be achieved ?
I'm thinking something with setContentOffset when the app starts to move the table view on top of the header. But then how do I do I know when the table view was dragged and released ?
You are correct that you can use setContentOffset to move the tableViewDown. You can implement UIScrollViewDelegate method scrollViewWillEndDragging(:withVelocity:targetContentOffset:) which will tell you when the user lets go of the tableView and then call setContentOffset(:animated:) to animate the tableView back to its initial position.

Adding a collection or tableview or custom view to a scrollview in ios 8

I have a UIScrollView with lots of sub views on the scrollview. I have a picture, buttons, textfields and the like that all work fine.
Now I want to add a comment section below all this that "acts" like a UITableView.
What is the best way to accomplish this? I want the comment section to load 10 comments when that part of the view appears, and continually add 10 more comments when the 6th comment appears. There should also be an activity indicator too.
I know you can't put a collection view or tableview with a scrollview (according to Apple) as their are inherited from UIScrollView. And making the whole view controller a table view or collection view is tough since I have so many subviews and actions all linked up already.
What's the best approach?
Thanks.
You can create a new table view controller and load (add subview on cell content view) your current controller as first cell of table view controller.

Multiple UITableViews visible at once in one UIViewController

I have seen questions asked about mutliple UITableViews in one view but they all have only one table visible at a time. I am after something different please.
In my head I want four UITableViews visible in one UIScrollView inside one UIView. The four tables will be visible and populated at once. They will have a dynamic number of rows each so the scroll view will allow users to scroll off of the page to see rows that do not fit.
The tables would be two side by side and then below them the next two side by side so that you end up with a 2x2 square.
I can (sort of) wrap my head around how to code this in the controllers etc. but I cannot figure out how to organise the hierarchi. I have tried using the storeboard to layout the tables inside the view but 9 out of 10 attempts to drop controls in fail as I am obviously not fully understanding this.
Do I need to generate the UITableViews in the UIViews implementation file and add them as objects to the UIView? Or can I use the Storyboard?
Could someone please explain how the hierarchi of objects would be structured?
In my head it would be:
UIViewController
-> UiView
---> UIScrollView
------> UITableView
------> UITableView
------> UITableView
------> UITableView
But trying this in Storyboard doesn't work. I assume each UITableView will want its own UITableViewController and what I have read in other posts I would likey need to do this connecting in the UIViewController implementation file.
Any help is appreciated.
I think you might try to drag UITableViewController into your view Controller, at least I don't have that problem to add 4 table view into a scroll view.
here is how i added it
1.> Drag the scroll view control into view controller
Your view controller should look like this:
2.> Drag the table view control into the scroll view, and set the size and position of that table view
Your view controller should look like this:
3.> Then drag all the rest 3 table views onto Scroll view
But i would like to suggest a couple of things in your case
no using that much table view in the same view controller, it's a chaos in your codes to maintain all them. There are always better
options than 4 table view, maybe consider collection view. or even
separate the use flow.
If i were you, i won't use table view inside Scroll view, they are like scroll view inside scroll view, if you don't design the
interaction very very well, they become extremely hard to use.
If you still want to use four table view in the same view controller after all, you want to pay extra attentions on your table view datasource and delegate. very carefully handle all the cases.
Hope that helps you.
Tableviews are very customized scrollviews. I wouldn't put 4 of them on a scrollview, this wouldn't be very intuitive for the user as your finger would scroll the view in many ways depending on where exactly it touches the screen.
Instead, try having your 4 tableviews in a 2x2 pattern directly onto a simple UIView. This can be done inside the Storyboard.
As for filling up and using them, you have 2 ways :
A) Your UIViewController is the delegate and datasource of each of the 4 tableviews. When executing, you perform a switch on the first parameter (the tableview that called you) to determine the appropriate course of action.
B) You create 4 classes that each handle a single tableview, instanciate 4 objects inside your UIViewController and assign the UITableviews' delegate and datasource properties to these objects.
All technicality aside, 4 tableviews in a single screen is pretty crowded. Your design will definitely not fly on a iPhone, so I'm assuming iPad only. Even then, you should make sure that everything is visually appealing and the purpose of each control is clear. It's up to you, but I'd hate to see you work hard on an application only to see your efforts wasted because your visual design doesn't appeal to your users.
If the table views take up the entire region of the scroll view then they wont let any scroll events past to the scroll view that contains them, unless the scroll is horizontal.
For a simple one to one between a table view and a view controller, I would make each table view part of it's own UITableViewController (so you have four), and then make a UIViewController that adds each of the UITableViewControllers to it as a child.
This way you don't have to do any fancy logic around if statements on which tableview is asking for data, because the table view controllers only have one table view.
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html

How to place a button below a UITableView managed by UITableViewController

I have a screen with a table view managed by a controller based on UITableViewController. I would now like to affix a button to the bottom of the screen so that it does not scroll along with the table view cells.
Replacing the UITableViewController with a plain UIViewController is not an option, as I want to include a UIRefreshControl. From what I have read, using a UIRefreshControl without a UITableViewController is currently not possible without resorting to any hacks / relying on undocumented behaviour.
I tried using a UIToolbar provided by the navigation controller which my table view controller is contained in, but there are two problems with that approach:
I only want the toolbar with the button to be present in the top level table view. However, I have not found an elegant way to only show the toolbar for the top level table view. I want the toolbar to animate out of the screen to the left together with the table view when I drill down.
I have not found a way to increase the height of the toolbar. Would I have to put the button in a dummy UIView?
This is approximately what I am aiming for:
http://pic.rockmynews.com/img/free-iphone-app.png
Another idea is using a container view controller containing the button at the bottom and the table view controller above it as its child view controller. But that seems a lot of work for something this simple.
So what is the best way to do this? Any recommendations?
Create the UIView container view. But also create a UIViewController subclass to manage the container. Then, add your existing table view controller as a child view controller and add the table view as a subview. Now you can control all of the subviews and positions while still having automatic refresh control operation.
Just use
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
and return a UIView for the desired button. and
tableView:heightForFooterInSection
and return the footer height
If you aren't willing to use a container view controller, you could use a third-party pull to refresh control like https://github.com/samvermette/SVPullToRefresh instead. This has the added benefit of being backwards compatible with iOS 5, if you want to support it.
You can use a UITableViewController. Just override viewDidLoad and then resize the tableView to make room for your extra view and then add your view programmatically. Make sure to set the right resizing mask so that things look correct on different screen sizes. (Easily tested in the Simulator by trying it out on the iPhone4 and iPhone5)

iOS6 - Changing embedded subview in a view

I'm looking for some ideas what's the best way to implement the following behaviour (and a starting point in code/pseudo-code if possible):
BookViewController with ViewA - contains some UILabels (e.g. information about a book)
MainViewController with ViewB - contains some UI elements and displays ViewA in the middle (one view at a time)
The user should be able to swipe inside ViewB to view different books i.e. I will need to manage a number of ViewA views, create new ones and populate them with new data, and then replace the current instance visible in ViewB. So effectively I'll be changing views in the centre of the screen. What's the easiest and most efficient way to accomplish this functionality? Any suggestions comments are appreciated - thank you.
You just need one view controller. It should control a scroll view with paging enabled at the center and e.g. three book views, one visible and the ones left and right of it. The controller should manage the data displayed in these book views.

Resources