UITableView with large static cells doesn't scroll to where it should - ios

So I have a unique iOS project (read as clients accepted a design before I started working here and the design contains checkboxes, dropdowns, tabular data (rows+columns,etc.) which requires a long tableview which contains 3 sections, the sections themselves vary from 50-700pt.
It appears this wasn't something Apple took into account as the table view does not scroll properly to all cells, specifically, when the keyboard is not yet open and I click on a textfield at the bottom of a long section it scrolls to entirely the wrong section.
I'm curious if there is something obvious I'm missing, I've tried using the library TPKeyboardAvoiding to no avail, it sounds very promising but also doesn't handle my situation.
I'd prefer to stick with a table view instead of a scrollview as I've already built out and handled headers, certain events, etc.
ALSO, after reading other posts it may be pertinent that I'm in landscape mode only on iPads and this tableview + controller is inside a container controller so it's size is fixed at 984x543

Related

XCode autocomplete

I'm new to IOS development, I have a few questions.
1) What's the purpose of property rowheight on table view cell, I mean it does nothing even if I change its value, it always takes the value from its parent view i.e a tableview property rowheight? It visually changes in the IB but nothing happens when I run the app.
2) What's the purpose of Content View why is it even there? Let's say If I have to make some image equal to the height of the cell it restricts me. Or is there any way a content view can be changed to be equal to the cell height & width? I have to put constraints on the image in relation with the cell which is not the immediate parent of the image and I don't know if this is the correct way to do it.
3)How does Xcode Autocomplete works? like if I want to write a function tableview(_:tableview didselectrowwithindex:IndexPath) and I type tableview it shows a list, what to do next? I mean I can't type the whole fucntion with params or find the func in the huge list.
The height of the cell set at the IB is primarily used for simulation, the views described at IB are normally resized when actually used. E.g. you can set rows height to be 100 for the table view, 30 for some of the cells and keep the whole controller simulating a nice screen of iPhone 6. The same view will be used for all devices and will be scaled accordingly as well as the cells with the help of your delegate.
The content view is there for the reasons directly related to your additional requests. It holds all the content while there other views that accompany your content and are part of the cell like separators, accessory views, slide action views. Without a content view the responsibility of managing all the additional parts would most likely fall on you as a developer and while you might think that that is fine at the simple layouts, a simple enhancement to it would make a huge impact.
Fuzzy autocompletion at Xcode seems to be something Apple is working on now. If you can't wait and find it too difficult to navigate through the list, there are Xcode plugins available that provide fuzzy autocompletion.
Answering the question in the topic:
example: tableview(_:tableview didselectrowwithindex:IndexPath)
if you write tableview it will show all the symbols that start with tableview. For functions, it will show all the functions sorted by the second parameter name (didSelectRowWithIndex).
[EDIT]
it will autocomplete as far as the answer is unique and then show you a list full of options. I don't know any tricks to skip looking through the massive list. But after a while you'll know what you're looking for and it gets faster.
[\EDIT]
when you press tab, it
by the way: the delegate functions names start with the name of the object they're related to.
So UITableViewDelegate functions start with tableview.
as for your first two questions there are tons of answers for those questions on SO. This one seems closely related to yours.

What type of view is the Twitter profile on iOS? UITableView?

Is the twitter profile view in iOS just ONE very dynamic table view? What's in the header and what's in the cells? I've just started developing for iOS and I'm trying to look at the big players and identify what they use and how they use it.
I've made a similar view, but it's a view comprised of carefully placed subviews, and I'm wondering if something like this would be a better route.
If it is a UITableView, how do they have such dynamic cells with different spacing between them etc? I know you can vary cell sizes, layouts, and insets, but to this degree, in one tableview?
Please don't jump me with downvotes for asking a non-technical question only twitter devs know for sure, I'm just really curious and don't know where else to ask. I'm only looking for a professional opinion.
It looks like it could be a very dynamic UITableView to me. Or at least, it could probably be recreated as a UITableView if it isn't already.
I'm looking at a twitter profile page now, and I would say there's probably 5 sections:
Header (everything from the profile picture to the "follow" button)
Recent Tweets (including the "view more" button)
Photos
"Special" items (Following, Followers, Favorites and Lists)
Who to Follow
The only component of this view that strikes me as particularly unique and special is the banner image that blurs and zooms when you pull down too far. I'm not quite sure how they pulled that off. It's possible that they track the offset of the scroll view, and if the offset is positive (i.e. it was pulled down), then zoom and blur the banner (and use the offset value as a scaling factor somehow).
All the other components could be probably be recreated by (carefully) designing custom UITableViewCells for each unique purpose (e.g. tweets, image carousel, other profiles), and then populating those cells with data from the tweet or profile.

UITableView tableHeaderView user interaction not working

I'm using a table view with a very large header view (not section header) in order to take advantage of the various advantages of table views (performance on long lists, pull to refresh, etc).
The header is ~700 points tall and contains various interactive items - a map, two buttons & a horizontal collection view.
Currently, none of the touch events are being passed through to the controls. I have tried building my own UITableView subclass, overriding the touch events & sending them to the next responder, but this doesn't help.
Strangely, the table still scrolls fine, so I'm not sure why that's happening. I have confirmed that the events are firing through debugging.
As extra details - I'm using iOS 7, Xcode 5, autolayout is on & I'm using a lot of constraints. None of them are listed as conflicting though.
Any idea how I should resolve this?
Thanks
Okay, so I managed to get this working & to be honest it's difficult to tell exactly what it was I did which fixed the issue.
Basically, I had wrapped all my controls inside a main view in order to be able to apply a total height constraint to it. That view did have user interaction enabled, but it seems like it wasn't passing the events through for some reason.
In any case, I removed that wrapping view & everything is now working.
shrug
I actually embedded all my header.xib controls into a View. After that, I was able to click on the buttons.

Giving a grouped UITableView "First Crack" at touches when using a section header view containing a control

I am using a standard grouped style UITableView that returns a custom header view for one of it's sections (using the tableView's delegate method viewForHeaderInSection:). The view that is returned for the section header contains a control. It displays an image and is a control so it can tapped to let the user change the image. My desired UI is similar to the photo for a contact in the Apple Contacts app (a floating imageView-like control in a grouped style table).
The problem I'd like to solve is that touches on the tableView section header go straight to the control. I'd like the table to get a chance to determine if the touch is actually the beginning of a scroll gesture. If not, then the table can pass the event to the section header view for processing.
This is how all the rows in the table behave since I have "delaysContentTouches" for the table on. I suspect the problem is because the section header view is not in the table's view hierarchy. So everything is probably working per spec. just not the way I want.
I want the section header view to behave regarding touches just like rows do (table gets first chance to process).
BTW I am not placing this control in a table row (which would solve the problem) because I want the rounded rect grouped style for all table rows, but not for this one UI element. This control is in the center of my table (header for section 1) which is why I want drags on it to scroll the table.
OK, so apparently this is simulator issue only. On a device my tableView gets the first chance at the event. So I guess I need to listen to the Apple mantra of "always test on an actual device" before posting to StackOverflow. Sorry friends... may my error be helpful to others who, like me, probably spend too much time in the simulator.

Objective C: How to implement a datagrid view (tables with multiple columns)

I am currently working on an iPad application that uses a table view to present data, I was inspired by the iTunes application in iPad that present it's data in multiple columns in a very nice and neat manner, and the most interesting thing is that during the portrait mode the itunes application displays data in 2 columns but when the user switches to landscape mode, it switches the display to 3 columns (since there are plenty of space to display data horizontally).
This is what i'm talking about:
but i found out that iOS SDK only supports single column for tableview (it would be nice to utilize the entire space provided on iPad screen to present data), i did some research and i found out that the best way to present data in multiple columns yet like spreadsheet style is to use datagridview instead, but iOS SDK did not provide any data grid view controls for iOS developers.
I found out over the internet some customized tables like:
AQGridView.
DTGridView.
and also the one from this:
http://usxue.is-programmer.com/posts/14176.html
and the one from this:
http://xebee.xebia.in/2011/04/14/building-editable-gridview-for-iphone-apps/
But sadly none of these ever met the requirements of the application i was working on.
Could you guys provide me some ideas or share some sample codes or links on how to display data in somehow-data grid view, to achieve similar effect used in iTunes application (as shown above).. Any form of help would be pretty much appreciated. Thank you guys!
The summary answer is, place multiple data "views" across in a single cell.
The more detailed answer:
Create custom views that represent the single cells you want. You can for this purpose make them resizable enough to work two across or three across (they will get loaded into 1/2 or 1/3 of the cells bounds).
Then make a custom UITableView cell, that can take two or three data items - load up an instance of the custom view previously created in the cell for each data item you have, placing them next to each other. You can have the cell do the view layout when groups of data items are added.
In the cellForRow code in the table delegate/datasource, you use your data source in groups of two or three (and report the row count accordingly) to pass along to the custom cell.
Sorry I can't share code, but I have used this technique before in other applications.
What's wrong with creating a UIView class to represent a single cell, and another that lays out an array of those cells in a grid? Put your grid view in a UIScrollView and you're about done.
UITableView is obviously a pretty complex class. Much of that is to make it very general, very reusable, and able to support a huge number of rows. Your class doesn't necessarily need to be that complicated -- if you have a fairly small number of cells, your "grid" could really just be a UIView in which you lay out cells in rows and columns. UITableView removes cells that aren't seen in order to save memory; you might need to do something similar if you have hundreds of cells, especially if they're large, but a few dozen probably won't require that.
In short, since you need a grid view for a particular use, you don't need to do all the extra work that would be required for a general, reusable solution.

Resources