Swift Pull to Refresh with UIViewController without TableView or TableViewController - ios

Is it possible to add a pull to refresh in a normal UIViewController that does not have a tableview or tableviewcontroller? I want the functionality to repopulate some fields that I have in my view controller.

Are you using a UIScrollView or UICollectionView? In both of those cases you can add UIScrollViewDelegate methods, specifically scrollViewDidScroll to your delegate and there begin your update when you want to.
If you are not using a scroll view, you could use a UIPanGestureRecognizer to do the job.

You have to make your own. You can e.g. use UIScrollView for this.

you can use this custom control (https://github.com/spbvasilenko/VASRefreshControl) it can be used with a scroll view.you will need to put your view in scroll view. hope it helps

Related

How to add a button in the TableviewController?

I was wondering how to add a simple static button at the bottom right of the Tableviewcontroller background, its will be contact infos.
I have tried through through the storyboard with no success.Do you have any clue for that?
Thank you ,
Regards,
Take ViewController and Add TableView inside it.
Take one View and set the bottom of the view controller and set button inside that View.
I would suggest you to make a normal ViewController, add a tableView and save an space for that button, take note that you have to set the delegates and datasource for that tableview.
You could use footerView if you want this button to appear only at the bottom of the whole TableViewController. To do that, you can drag a view after the cell in the hierarchy:
If you really want to use a UITableViewController, you could create a normal UIViewController, add a container in it and embed a UITableViewController in the container. Here's an example:
Create a UIView with UIButton and set this view as TableView's FooterView

iOS Drawer and Header Image within SWRevealViewControllerSeguePushController

Ho can I add header image to SWRevealViewControllerSeguePushController menu in iOS?
For example like material drawer have it for Android:
Can I modify somehow that UI Table View controller to put some custom UI above the menu rows or any other workaround?
Make a seperate UIViewController.
Add your custom views and a tableView to it.
Make the Delegate and Datasource for the tableView your viewController class.
Also i'd recommend making an IBOutlet for your tableView so it acts just like a UITableViewController (which behind the scenes is a just a normal UIViewController with its view being a UITableView and the delegate and datasource for the tableView being the view controller itself.
Yes you can definitely modify. Use any viewcontroller in place of tableviewcontroller.You will be able to add anything on it's view and do whatever you want. Good luck.

Collectionview Controller vs Collectionview

I'm beginner at IOS. I don't quite understand what is difference between collection view and collecionviewcontroller and in what cases can I use each of them
UICollectionView inherits from UIScrollView (just another UIView)
UICollectionViewController inherits from UIViewController..
and it implements some protocols.. like UICollectionViewDelegate and UICollectionViewDataSource .. it means everything is already done for you.. and you just have to use it.. but as everything is already done for you.. you may not be able to do some stuff.. like resizing your collectionView ..
if you want full control I recommend you to use your own UIViewController.. and add a UICollectionView as a subview.. so you can place it wherever you want and resize it.. don't forget to implement UICollectionView protocols for delegation and datasource :)
It's based on your requirements. You may change some properties with your View controllers. But when you use as part of its' controllers, you can't change it.
For example you CanĀ“t change UICollectionView Size of UICollectionViewController.
In these case, you must use UICollectionView in viewcontroller. As like this, if you want to customize some property but functionality are same in all.
Here I mention some ref for you: refrence
UICollectionViewController is specialized in managing UICollectionView. Collection view controller is inherited from UIViewController specifically for collection views so if collection views are removed then there is no use for Collection view controller.
Having said that,collection views can be used inside UIViewController whereas UIView can't be added inside UICollectionViewController.

UITableView inside a UITableView?

Generally:
Is it OK to add a UITableView as a subview of another UITableView? Or, should I create a UIView and add each UITableView to it?
Specifically:
For a ComposeTableViewController with a typeahead, like in the iPhone's native Mail app, which approach would you recommend and why?
Note: I prefer to construct things 100% programmatically (no Interface Builder).
Subclass UITableViewController.
Then, to show the typeahead results, create and add a resultsTableView as a subview of self.tableView positioned directly underneath the the cell (of self.tableView) with the typeahead text field.
The nice thing about this approach is that resultsTableView scrolls with self.tableView automatically.
But, is it OK to add a UITableView as a subview of another UITableView?
Subclass UIViewController.
Create and add tableView (custom property) as a subview of self.view.
Create and add resultsTableView also as a subview of self.view.
The annoying thing about this approach is that I have to reposition resultsTableView manually anytime self.tableView scrolls.
I think I'd prefer approach 1, but adding a UITableView as a subview of another UITableView just seems smelly to me.
TableViews cannot have subviews. You can try adding a tableview as the view of a TableViewCell, but then you have to ask yourself how it would scroll, if you tried scrolling in the subtableview would it scroll the child tableview or the parent tableview? It is much easier to present multiple tableviews within a view. This can be done easily by setting your custom viewcontroller as the datasource of both tableviews contained within its view and then comparing the tableview pointer that is sent as a parameter of the datasource method to the two tableview pointers that are IVars of your custom view controller.
Hold stuff like this in a container. Create a container view controller which only does typeahead. This container view controller will hold your main table view controller (and its table view) and it will hold the typeahead view controller (and its view).
It will keep the logic needed for the typeahead out of your main table view and as a bonus you might end up with a reusable typeahead container which could be applied to other views.
Yes it is good to go for adding UITableView in as a cell of another UITableView.
I had one issue and posted a question
Multiple Views as subviews
And requirement was like a group of controls with list of other controls. I thought that time that it will be messy if i'm going to add UITableView as a cell of UITableView.
What i found that... Boy !! it's how iOS meant to be. There is no any lag while doing this.
Tested for below functionalities:
Scrolls like a charm
Separate delegates called for each
Reordering of both UITableView cell
Swipe and remove cell
Runtime datasource update for both UITableView and reload both at the same time.
There is no any reason not to add subview UITableView.
You can do it but it is against the principle of MVC. You will be setting the delegate of a view to another view which is wrong.

Can't change the size of a TableView in Interface Builder

I'm trying to change the size of a tableView I have in interface builder and can't seem to. When I first started the app I could drag it around and stretch the sides but all of a sudden I can't adjust it. I tried to delete my tableView and add a new one but the same thing happened. Thanks in advance. Here's what I see when I try to change the size:
if your using a UIViewController you can drag and drop a tableView and can place in a custom position you want. but if your using a UITableViewController you cant move the tableView to your custom position. if you want to do it in UITableViewController you can do like below
if you want your tableView content should show from a point, that you want you can do this way,
[self.tableView setContentInset:UIEdgeInsetsMake(100,0,0,0)];
else if you want set your tableView to a frame in UITableViewController you do this way,
- (void) viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.tableView.frame = CGRectMake(0,100,320,300);
}
hope this will help you.
What kind of view controller are you using to manage your table view? Since you show "prototype cells", I'm guessing it's a UITableViewController. Those are built to fill the entire screen with a single table view (which has always annoyed me.)
Starting with iOS 6, though, you can create a "container" view in another view controler, and then drag an embed segue from your container view onto the table view controller. That does all the housekeeping to make the table view controller a child view controller of the other one, and then you can make it whatever size you want.
If you don't want to use a UITableViewController as a child of another view controller, you can use a regular view controller and wire up the data source and delegate methods yourself. However, things like static table views and prototype cells don't work then.
Hopefully this helps someone still coming across this problem. What I did was make sure the UIViewController had a UIView as its direct child, then dragged the UITableView as a child of the UIView, this allowed me to resize the UITableView.

Resources