Custom TableView iOS - General questions - ios

This is more of a general question. I want to create a scene where the top 1/3 of the scene is say a slider with some text labels, and then the rest 2/3rds of the scene is a data table of recorded values of the above slider(user moves the slider to the correct value, hits 'enter', and the recorded value is showed in the data table below). I assume this is a modified table view, but I'm not sure? Can anyone point me in the right direction on how to go about doing this? Im not quite sure where to begin looking up information/tutorials on this type of layout. Any help would be appreciated!! Thanks so much!

It isn't a "modified table view". It's a table view. There's no problem here; you have a scene with a UISlider, some UILabels, and a UITableView. There is nothing to "look up". No law says that a UITableView has to occupy the entire scene interface - though of course in that case you can't use a UITableViewController, but that's no restriction at all. Just set your table view's delegate and data source to the view controller that owns the scene.

You'll want to create a UIViewController that contains the UISlider and a UITableView within it's xib file. Hook the view elements to its ViewController.h, and set your ViewController as a UITableViewDataSource and UITableViewDelegate.
In ViewController.m, fetch the data follow the UITableView protocols to load it into cells. Then, when you would like to refresh data call
[myTableView reloadData];
Apple's UITableViewDelegate Protocol
Apple's UITableViewDataSource Protocol

Related

how to animate section header of collectionview in tvOS app?

Need to animate the section header title when the collection cell below the header is focused. Just like if you go to "movies itunes" app on apple tv and go to top movies tab, if you look at the playlists below, when you scroll through items, the header animates, up and down to not to overlap with focused cell. any help is appreciated tvos screen shot link
I can't exactly provide the code; but this is basically what you're going to want to do.
1 - Create an intermediary class headingRouter; whose purpose will be to mediate between the scrollView header (collectionView or tableView) and the cell selection. An instance of heading router will live on your collectionView main level methods. You could use a delegate pattern to abstract out the image logic to the router and then on the collectionView; conform to the delegate in order to update the view in question.
2 - Headers and footers are what is called a supplementary view; so they can be assigned any custom subclass of uiView. In this headerView; you should have a method that takes in an identifier, possibly id and changes the image displayed. You can animate this change with a fade if you want it to look like iTunes.
3 - On your focused cell section; have the cells have an identifier that is assigned during the cellForRowAt method in your delegate/datasource methods. When a specific view is focused; using one of the various collection/tableView methods; you want to take that id; pass it to your headingRouter, which in turn will notify your header to change it's image to the corresponding image (possible held in cache) to the image you're focusing.
This is more the logic of implementation; but you haven't posted any code, so there isn't much of the way of specifics. You could do without the Router class but this is a cleaner solution.
Cheers

Load a TableViewController on an animated UIView

Is it possible to load a UITableViewController on a UIView?
I followed this tutorial in animating a UIView, but I want it to load a UITableViewController. The reason why I need to laod a UITableViewController is that i have 2 sets of buttons that will use the UIView but will display different types of tables with different type of icons. I am trying to recycle the UIViewController that I made it work using a popover menu when a button is clicked but I feel like a sliding UIView will give a better user experience.
Anyway, I'm basically trying to load a UITableViewController onto that UIView. Not sure if it's the right way, if not, is it better to just load a UITableView instead? I just feel like it'll have more code on one file and will be confusing when maintaining it specially if there are 2 different types of data or rows that needs to be loaded.
Thoughts?
Just load the table view instead. It won't be all that much new code - and you are using #pragma mark -, right?

OOP - Using a UIView to coordinate multiple subviews?

This is an Object Oriented Programming question:
So I am trying to build a UIView class that displays scatter plot. In my current implementation, I've created a datasource protocol that allows the chartView to ask for all the info it needs to plot the its data.
As it stands right now, when someone initializes the chartView and gives it a datasource, the chartview creates/manages several subviews: a 'dotsView' that displays all the data points, a scrollview to which the dotview is added (so it is scrollable), and a 'skeletonView' that sits in the background and displays other chart data like grid lines.
This system at first worked great, however, I decided that i'd like to animate changes to the points, and so i began to contemplate using a collectionView in lieu of the 'dotsView' placed within the scrollview since it'll handle the animation for me. However, as a collectionview would require a delegate, datasource, layout object, etc, all the sudden my chartView seems to looks more and more like a controller and not a view.
Now here is my question: Is it the wrong approach to allow a UIView to coordinate/configure other UIViews, even if those UIViews are a fundamental requirement of the whole? On the one hand, I'd love to preserve the simplicity of my chartView's public interface (initialize the view, give it a datasource, and you're done). On the other hand, this chartView is really not a view anymore, its more like a controller. But I don't want a consumer of my chart to think/treat it like a controller, I want them to use it as a view.
Any thoughts? I'd love to hear the insights of others.
Thanks!
It is totally fine for your ChartView to create a UICollectionView, use it as a subview, and be the data source and delegate for that subview, because the use of UICollectionView is an implementation detail of the ChartView.
Apple does this in UIPickerView. Under the covers, a picker view creates one table view for each component, and the picker view makes itself the data source and delegate for each table view. You can see in UIPickerView.h that it conforms to UITableViewDataSource. You can check that it conforms to UITableViewDelegate at runtime with +[NSObject conformsToProtocol:], or by using class-dump on the UIKit framework. Or you can just write a test app and poke around the view hierarchy. The debugger command po [[UIApp keyWindow] recursiveDescription] will get you started.
UIPickerView is the only view subclass in the iOS SDK that I know of that acts as the data source and delegate for its subviews, but many other UIKit view classes create and manage their own subviews. Examples:
UIScrollView has private subviews for its scroll indicators.
UITableView has private header, footer, section index, and row separator subviews.
UIButton has a private UILabel to display its text and a private UIImageView to display its image.
UISegmentedControl has private UILabel and UIImageView subviews.
UIProgressView uses several private UIImageView subviews to display its parts.
UISlider uses several private UIImageView subviews to display its parts.
UITextField uses private UIImageView subviews.
You answered you own question my friend: Is it the wrong approach to allow a UIView to coordinate/configure other UIViews -- YES!. Views should be casted by a Controller from an organizational stand point IMHO. I would build a Charting Controller that can cast out single and composite views and kill two birds with one stone. The you could route urls to the controller from Ajax to change the data represented in the chart

Embedding a UIScrollView with a UITableView

So Path uses this type of page where there is a view above their customized looking table that is a background photo, which contains some user info among other things. I'm trying to recreate something very similar to this.
So lets say that I hypothetically wanted to make a view that shows exactly the way the Path app does, but instead of that weird customized version of a table view that they have, there is an actual table. How would I do something like this? The reason why I would need there to be another UIScrollView embedded into the view is because the entire thing needs the capability to scroll. I'm trying to be as detailed as possible, but its a little difficult to explain.
What I'm imagining is going to happen if I just tried it right now, is that I'd embed a UIView above a UITableView within a UIScrollView that's the size of the frame, and when I'd go to scroll, the user would only scroll the UITableView, and not the entire thing at once. Hopefully that helps convey my doubts.
Another possibility is that I'm totally over thinking this, and I can simply just subclass a view in the header of a UITableView and it would stretch the width and height that I'd like. Hopefully this is the way as this would be easy!
Anyways, can anybody weigh in on this?
Path just uses a normal UITableView with UITableViewStyleGrouped.
The custom view at the top is the header of the first section of the table.
They also access the UIScrollViewDelegate method of the UITableView to change the look of the view (I think the image is moved) when the scroll view scrolls.
If you'd like a tableview that only scrolls within a part of the view and other stuff above it then you need to use a UIViewController. Then you can make it conform to UITableViewDelegate and UITableViewDatasource and add a UITableView and make the view controller the datasource and delegate.
Then you can also add a UIScrollView to it as well.

ipad populating table with coredata

Please help with this issue that is driving me insane...
I want to populate a table with coredata (in a UIViewcontroleer), not a UITableController, as I need the table to be small and not take the whole screen,
I have tried different approaches, to no avail, and no answer to fix the problems,
Im adapting some code from tutorials that use the whole screen,
example problem, Request for member tableView in something not a structure or union
all my searches for code show the use in iphone with tableview, It would be awesome if you know of a sample for ipad with a view controller (not in split view),
thanks in advance
Your error stems most likely from you using the tableView property which is not available in UIViewController. It's difficult to judge what you did wrong, did you implement the necessary UITableViewDataSource and UITableViewDelegate methods? If you implement these it's no problem to use a UIViewController with core data. But remember the UITableViewController does more than just fill the table, it also resizes the table view when the keyboard is shown. You'll have to do this yourself, too.
UITableView has a rowHeight property that you can set directly or via the delegate method tableView:heightForRowAtIndexPath:.
UITableViewCell has a font property that you can set, to make the font smaller.
UITableView class ref says rowHeight is in points. If that means the same as points in NSFont, it should be easy to coordinate the two.
And of course you can resize the table view’s frame in IB.
So you ought to be able to get what you want using a UITableViewController.
As for the error, do you know what line is generating it? Have you set breakpoints to find out?

Resources