Pull to refresh - Solution found but unable to implement it - iphone

I am using the example shown in the Pulltorefresh library. They have implemented it to fit a TableViewController class. But mine is a UIViewController, and i am adding a TableView in it.
I found a SO answer that shows a workaround for this. Can someone tell me how to implement it as described in the SO answer. Here's the link for the answer

That answer is not talking about using the library you are referencing. They are talking about how you would go about creating a UIScrollView with the "pull to refresh" functionality.
It shouldn't be that hard to transition the code to a UIViewController. Just change the code to subclass UIViewController and setup a UITableView property on the view controller (and make sure to set the data source & delegate of the UITableView to the view controller). There might be more to it but these are the basics. If you ask a more specific question about how to transition it to a UIViewController then maybe I (or someone else) can help more.

maybe you could try a different library?
I've used this one in the past, and it worked great!
http://cocoacontrols.com/platforms/ios/controls/egotableviewpullrefresh
Edit:
Here is the exact tutorial I used. He does exactly what you want. Adds the pull to refresh to a UITableView that is contained in a UIViewController!

Related

Programmatically made view with rest of project in main.storyboard

I have a quick question for you guys that I havent found a definitive answer to. I have a app made with every viewcontroller designed in the main.storyboard. Recently I had to change out my table view viewcontroller for receiving data with collectionView in order to implement some more features.
But I have made this view programmatically. And I have made it exactly how I want it.. When I was done I wasnt sure if I could even use it with my main.storyboard made project. Atleast no similar question I have found has given me the exact answer to that.
So I figured I should ask you guys if thats possible and if it is.. if its a complicated process. This is my bachelor's thesis work so I am working against the clock.
If anyone knows, and maybe even have some tips on how I do this, I'd greatly appreciate it!
If your viewController conforms correctly to all the necessary methods; you should be able to create a viewController in your storyboard; hook it up the way you would any other uiObject; and then set the custom class in the attributes inspector to the class of your ViewController.
If the view and not a viewController; you do a similar thing, drag the conforming type to your storyboard and subclass.
If you'd like to see your view render on your storyboard; have the object declare #IBDesignable before the class declaration.
#IBDesignable
class myView: UIView {}
Just present the programittaclly created view controller from code:
let view = YourViewController()
self.present(view, completionHandler: nil)
Hope this helps!

The best implementation of a tableview in Model View Controller

What is the best implementation of a tableview in Model View Controller?
I'm developing my app without storyboard, all programmatically .
Is it possible to implement a TableView in a UIView? I tried it, but If I implement the TableView in a view, when the controller recives a button action, I can't modify or access to the tableView of the View...
After that, I tried to implement the tableView in a ViewController and it works perfectly, but I don't know if this is a good implementation because I found the same problem when I wanted to implement a TextView/TextField with a Piker, for example.
My goal was to had a clean code of viewController with a views and controllers (of buttons etc) and now I find myself with a uiviewController with the view and multiples components when I wanted the components were in the corresponding views.
Thank you very much!
It is all possible, and the problems you are running into are not because of it being something that you should not do, but that it is something that inherently works slightly differently than before. To answer your question directly, I would implement the tableView as the modal view controller directly, either as a UITableViewController or a UIViewController that inherits the table views delegate and datasource (this method being chosen if you don't want the table view to use up the entirety of the modal view controller's space).
TableViews are simple to use, but understanding every detail of how they work will make you far stronger and able to use them in any of these scenarios. I am not going to write you a guide on their use, butcontinue studying them before you declare that anything "can not be done".
Knowing what classes to implement the delegate methods becomes very important during these different scenarios. It is often easiest to use textfields delegate's implementation in UITableViewCell's subclass rather than in the UIViewController they are in. This allows for a more modular creation.
I find that working with the storyboard allows for a much quicker learning curve, and also a time saver. The one excuse I will give you for working without a storyboard is if you have an extremely slow computer.

How do you populate a tableview with a class?

I'm looking for a good example on how to populate a UITableView with a class that will also push data to multiple detailed view controllers. One would just be a simple "about" page, the other a mapview. Does anyone have a good example of this or know if it can be done?
This can certainly be done! Although you'll have to explain me what you mean by "pushing" data to view controllers.
Usually, you'll have a class implementing the UITableViewDataSource Protocol to supply data to a UITableView.
Another (or the same!) class would implement the UITableViewDelegate Protocol to tell the table view how to behave and how to look.
Make sure to go through this guide about programming table view in iOS for an overview of the process.
This whole delegation pattern (discussed here) is also useful to work with MKMapView.
For a start, you can look into this example from the iOS Developer Library : https://developer.apple.com/library/ios/#samplecode/CurrentAddress/Introduction/Intro.html

Is there a Interface Builder-esque way to get that slick "pull down to refresh" menu I see on the Facebook iPhone app?

I've seen this in other apps too, so I'm wondering whether there's some canned functionality I'm missing. Is there an interface for the "pull down to refresh" action? If not, what's that called so I can Google it?
It is not built-in functionality but you can grab the open source version from the guys who originally implemented it :-)
http://github.com/enormego/EGOTableViewPullRefresh
No. You should look at EGOTableViewPullRefresh on GitHub.
This is an old question, but for anyone ending up on this page - This feature is now built into iOS - Just do a search on stack overflow or the web for UIRefreshControl.
I believe if you are targeting iOS 5.0 or later, this is the way to go - Its also super easy to implement
Just to round out the answers - you can make a table view in IB, put it in a view, and then change the type to be something like an EGOTableViewPullRefresh table. Then you just set an outlet for it and implement the delegate methods in the view controller.
In fact I find it very handy to use table views as a subview of a view in a normal view controller. The UITableViewController only provides a handful of convenience mechanisms.

Moving tableview into existing window in Interface Builder

In Interface Builder, I dragged a UITableViewController object from the library into the project. Then, a tableview popped up. How do I get that tableview inside my already existing window?
Thanks, I'm totally lost!
That tableview is part of the UITableViewController, and is connected to its view property. The second window pops up so you can set that UITableView's properties directly.
If you're just starting out, I'd suggest checking out a few tutorial. The site I started learning from is called http://icodeblog.com/, and I'd also recommend the Beginning iPhone Development book by Jeff LaMarche and Dave Mark. Also, if you have iTunes, the Stanford iTunes class is a terrific way to learn in-depth about iPhone development, and it is free to download from iTunesU.
If you have created a view based application, the thing that you need is to add a uitableview from the library to the view. Be sure that you add uitableview, not its controller. It will be seen under dataviews
You have to take UIViewController first and bind it with view. Then add UITableView in your controller and bind it with IBOutlet object of UITableView.
Then you have to set datasource and delegate of UITableView. That's all. Now you can access all the methods of UITableVIew inside your controller.
If you still find any problem then please let me know. I will definitely help you out to solve this problem.