manage size of presented tableviewController - ios

I have presented a tableview controller on a view controller.That tableview comes as full screen on view controller but I do not want to present the tableview on full screen.Is there any way to manage the size of presented vie controller. And the second problem is that i want to present a vie controller which have some label , some text boxes and a table view. Please help

IF you are using iphone device then the viewcontroller will occupy
the full screen .
If the device is iPad,then u can use modalPresentStyle.
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:yourVC];
navController.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentViewController:navController animated:YES completion:nil];
For iPhone ,add the views like UILabel,UITableview to the mainView and present it.

The UITableViewController is used when the table view is the main view of the controller.
In your case it seems more appropriate to use a normal (subclass of) UIViewController and add a UITableView as one of its sub views.
Then you can resize it as you prefer and add other elements (labels...) as additional subviews.
Usually in this configuration you may want to set the view controller as the delegate and dataSource of the table view.
Does this answer also your first question?

You could not change the size of the presented view controller. Another way to do it is by adding it as childViewController by:
[self.view addSubview:tableViewController.view];
[self addChildViewController:tableView];
Then you can change the size of the tableViewController as you wish.

Related

How to load second view ,that can see the first view thourgh it (transparent), in ios 9

This is my question,think that I have two views. in the first view there is a imageview(with a image) and a button.When I press the button then it load second view(with storyboard segue kind is present modally).when that view loads, I want to set the first view, through the second view(should be transparent).
I tried with setting secondview's defatul view background color to default but it gives black.how can I do that.
Oh i fixed you issue after a few minutes test...
I found that segue has a property named presentation,like this:
you may change the property to Over Current Context and it works
Select your secondviewcontroller goto attribute inspector then select Transition style to 'cover vertical' and presentation to 'over current context'
and write the code for presentviewcontroller to present your second view controller modally in firstviewcontroller.
You can add the view of one viewcontroller to another as a subview. This way the code for each viewcontroller is in it's own class, but they are displayed on top of each other.
MyViewController *viewController = [[MyViewController alloc] init];
[viewControllerA.view setFrame:CGRectMake(x, y, width, height)];
[self.view addSubview:viewController.view];

Modal View Controller with MapView And TableView

I'm looking to replicate the basic functionality of the Stores finder in the new Starbucks app (MapView with a tableview bellow it) but am unsure as to how I would go about implementing the sliding aspect of presenting the view
The main aspect of the functionality I am trying to replicate is the ability to present the modal and have it dismissible by sliding it down off the screen as I am able to replicate the Map + Table view already
https://www.cocoacontrols.com/controls/kipulltoreveal Just make a custom cell and you can make it identical.
Well from the Gif you posted, It seems that Starbucks just present the view controller modally which is very easy to do.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
YourViewController *yourVC= (YourViewController *)
[storyboard instantiateViewControllerWithIdentifier:#"yourView"];
[self presentViewController:yourVC animated:YES completion:nil];
As for dissmissing the view you would need to set ViewController's interactivePopGestureRecognizer delegate to self and then handle its behavior in -gestureRecognizerShouldBegin:
That is, when you want the built-in pop gesture (– popViewControllerAnimated:) to fire, you must return YES from this method. The same goes for your custom gestures - you have to figure out which recognizer you are dealing with.
My thought is this is just a viewcontroller containing 2 basic views:
The background view including tabs and your personal info page which is below tabs.
A table view occupying the whole screen.
section 0: header: empty header / no cells
section 1: header: search bar / 1st cell: mapView trespassing its bounds to cover section header / other cells: locations
Whenever you scroll down 'too much' they defined. They do animation to hide the tableview
To make it looks like a modal view, they make the map corner rounded.

Want to Push another View from current view

I am doing paypal integration and my project is working good.
But i want to push my Next view from my current view. first i used Navigation Controller but now i want to push it with out navigation controller.
I used the syntax with Navigation controller is
[self.navigationController pushViewController:[[[NextViewController alloc] initWithURL:[ECNetworkHandler sharedInstance].redirectURL returnURL:RETURN_URL cancelURL:CANCEL_URL] autorelease] animated:TRUE];
And i used the syntax to push another view controller without navigation controller is
NextViewController *webVcustome = [[NextViewController alloc]initWithURL:[ECNetworkHandler sharedInstance].redirectURL returnURL:RETURN_URL cancelURL:CANCEL_URL];
[self.view addSubview:webVcustome.view];
With Navigation it works but without navigation it don't.
What should i do to push the view controller.
instead of adding a subview call presentViewController:animated:completion, like this:
[self presentViewController:webVcustome animated:YES completion:nil];
for more information of this message take a look to the documentation
If you want to "push" a view without using UINavigationController , I think you can only use two views to adjust their frames when they are begin "push" movement.
eg:maybe you can creat 2 subviews such as : currentView , anotherView. And then add them to the self.view.
maybe you can set the currentViews frame is (0,0,320,480) and anotherViews frame is (320,0,320,480) , when you want to "push" them , you can set their frame is the currentViews frame is (-320,0,320,480) and anotherViews frame is (0,0,320,480) with a UIView animation

popover content view doesn't display while viewcontroller has a child VC present

I have a container view controller that consists of a navigation view at top, and a content view for the remainder of the screen. The navigation menu consists of several buttons, some of which present a popover with UITableView for secondary navigation. This all worked until I assigned a child view controller and set it's view as subview of the content view. Now, the popover appears, but has nothing inside it (no tableview, just black).
Why is this?
Here's the code I added for the child vc in container view:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
ContentWebViewController *initialVC = [[ContentWebViewController alloc] init];
[self addChildViewController:initialVC];
initialVC.view.frame = self.view.bounds;
[self.containerView addSubview:initialVC.view];
self.currentController = initial;
}
See the screenshot below. I added a vc with a simple webview showing google (just as a placeholder for now). The popover was working fine before I assigned the child VC.
Maybe it will help other in other cases -
If you are using size classes (probably you are since you are developing this to iPad) -
Design your popover view controller in Any-Any size and it should be OK - after that you can return to your wanted size.
(You can also uninstall the size classes of any object in that view controller instead of redesign the VC)
I somehow (don't ask me how) changed the class that my table view controller was inheriting from. It should have been (obviously) UITableViewController, but was UITableViewController, so initWithStyle was not being called....

Setting a title and a UIBarButtonItem in WePopoverController

I am implementing a WEPopoverController and would like to set the title and put a button on top of the popover. Is it possible to do that with this controller?
This is what I have so far. I am loading TableViewController into the popup.
I tried to set self.title=#"title"; in the tableviewcontroller's viewdidload but that didn't help. I only see the tableview with borders inside.
I tried to create a tableview controller in storyboard and programmatically load into the popup but i couldn't resize it. Plus i am not sure if that would be good programming practice.
This is how i load the popuptableview. Would it be easier to use a UIViewController? I don't really need the tableview.
PopUpTableViewController *popUpTable = [[PopUpTableViewController alloc]initWithStyle:UITableViewStylePlain];
// TestViewController *testView = [[TestViewController alloc]init];
self.popoverSettingsController = [[WEPopoverController alloc]initWithContentViewController:popUpTable];
[self.popoverSettingsController presentPopoverFromRect:frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp
animated:YES];
I looked through the preference options but didn't see anything about title. Would i have to resize the container?
You should create a navigation controller with your popUpTable as root view controller and then use the navigation controller as the content view controller for the pop over.
If the above is done, then your logic of self.title inside popUpTable and creating bar button item will work!

Resources