swift3 Table Views in Container Views laggy and not displaying properly - xcode

I have an iPad UI set up that different views are loaded into a container view on a button press.
Most of these views have 1 or 2 table views in them
When I try to press on the cells in the table views it is very slow and sometimes I have to press for 6/7 seconds before it will call the didSelectRowAt function.
One of these tables also has a custom cell, with 2 buttons. Only the very right portion of one of these buttons is visible, the rest of the button is hidden, however still calling the touchUpInside events.
Does anyone know how to fix these issues?

Related

Why is my view loading but not displaying with segue?

I have a bunch of views (5) and a navigation controller the user can go through by pressing buttons that segue to the next view (each view has something the user does and sends data to the next one). My app is connected with a Firebase database, so I'm doing some stuff with that.
Anyway, the view I can't get to work is a TableViewController which works as a checklist, the user must select a certain number of cells, then clicks next and an array is sent through the prepareForSegue to the next view and this view should be display. It isn't. I have some code and some prints in the viewDidLoad that let met know that the view is supposedly loading, just not being displayed.
The screen freezes and the button just remains pressed. It doesn't crash, just stops.
My code has nothing special. It just has a performSegue in the first view and nothing really in the second one.
This is the way they're set up:
https://imgur.com/a/cyO47Pl
I've been told the problem is that there are too many push segues or something like that, could it be?

Why do I need wantsLayer for Check Boxes in a Table View in macos

I have a simple cocoa app for macos, the whole UI is created programmatically i.e. I'm not using the interface builder (no xib-s, no storyboards).
I'm creating a scroll view, adding a table view with a single column and feeding it with cell views containing check boxes.
So the view structure looks like this:
window
root content view
scroll view
clip view (created automatically by the scroll view)
table view
cell view
check box
The problem is that the check box is behaving weirdly in this structure - it doesn't repaint itself when clicked. BUT - if you click it and then resize the window (I have auto-layout constraints there, too), then the table view is redrawn and the check box is redrawn too and thus updated.
I've been trying various things to localize the problem (I'm new to macos, therefore I tried pretty much everything) and found out that if I turn the wantsLayer on for the cell view or the check box itself, then check boxes start working properly.
If I don't wrap the table view into the scroll view, then everything works without wantsLayer, too. When I create check boxes out of the table view - just put them on the root view itself, they also work properly.
Please explain me why do I need the wantsLayer. Or maybe I need something else in reality and wantsLayer works just by accident?

Overlapping cells in static tableview built using storyboard

All,
I'm using the Xcode 6 beta to build an iOS8 project using storyboard and swift. In the storyboard, I've created a Table View Controller as my primary view when the application loads and have added a label to the first cell and a label to the second cell.
The table looks fine in the storyboard, but when I run the application, the cells overlap. This is a brand new project with no other changes made or code added.
You can see both the storyboard and the running application in the photo below. Any ideas on what could be driving this?
Additionally, when I try to add a button to one of the cells, I get a grey box that covers 90% of the view.
I think I've had this issue. Try making some Auto Layout connections from the label to the Content View of the cell, and from the table view (and its cells) to the containing view, to force the views to be the proper size.
The following worked for me.
Control-click and drag from your label to left side of the cell it's in. When the modal comes up, check the box for 'Leading Space to Container'.
Repeat the same Control-click and drag process for each side of the cell, selecting the relevant Auto Layout option when it appears.
(Optional) Try to Control-click and drag from your table view to the each side of the containing view (if there is one), and repeat the steps from above.
Hopefully this works for you.

Swipe gesture without messing the navigation bar?

This is hard to explain but i'll try my best. I have a Table View controller that leads to 10 View controller. All the View controllers have a navigation bar title (The titles are the 10 objects from the Table view controller). Now i want to add the Swipe Gesture for a easier navigation between the 10 table view items (Instead of going back to the Table view manually i want the user to be able to swipe to change from a view controller to another). HERE'S THE PROBLEM: When i add the Swipe Gesture and i connect it from one view to another, it asks if i want the action to be either: Push, Modal or custom. Now, if i choose one of them, it makes the navigation bar title disappear. I want to keep the title without messing up the connection from the table view to the views controller. Thanks.
You want a pageviewcontroller. Set up the pages to be your different view controllers
A pageviewcontroller essentially allows you to do exactly what you want to do without having to setup a new segue every single time. That way it can all happen under one navigation bar. If you've seen the twitter app, you know how you can scroll through your feeds? Same thing.
There are tons of tutorials on the web, but pageviewcontroller a can be a tiny bit tricky because they require some logic
Here's a slightly more advanced thing that might be useful to you:
https://github.com/cwRichardKim/RKSwipeBetweenViewControllers

How do I check if a NSView is being displayed at the moment?

I got an application which has a NSToolbar in its main window. Depending on which icon is clicked a NSView is displayed in this window. My problem is, that one of these views shows data in a NSTableView that I want to be reloaded each time the view is visible. Since -init is only called once, I don't know how to do that.
(example: When the application starts it shows the Documents section [on of the sub views of the window]. Now when I click on Employees [which displays another sub view instead of the first one] and then on Documents again, I want the data in Documents' NSTableView to reload.)
How do I do that?
Thanks in advance.
I got an application which has a NSToolbar in its main window. Depending on which icon is clicked a NSView is displayed in this window.
Use a tab view. You can hide the tabs, then implement your action methods for the toolbar items to act as the tabs, changing the selected tab view item to whichever one corresponds to the pressed toolbar item.
Now when I click on Employees [which displays another sub view instead of the first one] and then on Documents again, I want the data in Documents' NSTableView to reload.
Why? Why not reload it only when the data changes?
You don't have to hold NSTableView's hand; if it needs the data from you again, it'll ask you for it again.
And if you're concerned about reloading the data while the view is not visible, that's premature optimization. Don't worry about it until you prove via profiling that it is a real performance problem.

Resources