Modal that displaying from UITableViewCell - ios

How to display a modal popup that look like from a UITableViewCell (look like option ), which displaying a custom controller?
I'm trying to achieve something like contact app does ( see below ) :
Below is my current implementation, which only displaying common modal :
TSCAliasViewController *V2 = [[TSCAliasViewController alloc] initWithNibName:nil bundle:nil];
V2.modalPresentationStyle = UIModalPresentationFormSheet;
V2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:V2 animated:YES];
V2.view.superview.frame = CGRectMake(0, 0, 400, 300);
V2.view.superview.center = self.formView.center;
Any idea?

You need to use UIPopoverController. Currently it works on iPad only!

Related

Custom UIView like UIPopoverController

Would like to learn how UIPopoverController style UIViews are created.Below is the image from Storehouse iOS app running on iPhone(apple design award winner) , you can see the view moreover looks like UIPopoverController ,any help is greatly appreciated.
You can handle your own custom view check out this How to Place custom view in IOS over another view
You can use this
- (IBAction)ContinueToPayment:(id)sender {
PayByVC *Newpage = [[PayByVC alloc] initWithNibName:#"PayByVC" bundle:nil];
Newpage.checkOutInfoDict=checkOutDict;
Newpage.modalPresentationStyle = UIModalPresentationOverCurrentContext;
Newpage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
Newpage.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.4];
Newpage.delegate = self;
[self presentViewController:Newpage animated:YES completion:nil];
}

CLViewController, display detail view in fullscreen, iOS sdk

I am working on iOS application and i have used the split view like structure which Facebook application has.
I have used the code which has the CLViewController, This code i have found from google.
All working fine but in my current application when the app loads the first screen itself shows the split view in which 80% screen shows the menu and 20% shows the detail page. I want to change it in a way the Facebook app works. In Facebook on loading app directly shows the news feed. so same way i want to load detail page first.
If anyone have any idea how can i achieve it please share.
Thanks in advance.
Code : How to use SWRevealViewController
Here first initialize your View controllers
FirstViewController * first = [[FirstViewController alloc]init];
SecondViewController * second = [[SecondViewController alloc]init];
Create BarButton....
UIBarButtonItem *revealButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"reveal-icon"] style:UIBarButtonItemStylePlain target:_revealVC action:#selector(revealToggleAnimated:)];
Put firstViewController and secondViewController into Navigation
First hide self.navigationbar
self.navigationController.navigationBarHidden = YES;
UINavigationController * navigationController1 = [[UINavigationController alloc] initWithRootViewController:first];
navigationController.navigationBar.topItem.leftBarButtonItem = revealButton
UINavigationController * navigationController2 = [[UINavigationController alloc] initWithRootViewController:second];
navigationController.navigationBar.topItem.leftBarButtonItem = revealButton
Initialize SWRevealViewController
_revealVC= [[SWRevealViewController alloc]initWithRearViewController:navigationController1 frontViewController:navigationController2];
_revealVC.rightViewController =nil;
_revealVC.rearViewRevealWidth = 60;
_revealVC.rearViewRevealOverdraw = 0;
_revealVC.bounceBackOnOverdraw = YES;
_revealVC.stableDragOnOverdraw = YES;
_revealVC.rightViewRevealWidth = 350;
_revealVC.rightViewRevealOverdraw = 0;
[_revealVC setFrontViewPosition:FrontViewPositionRight];
[_revealVC revealToggleAnimated:YES];
[self.navigationController setViewControllers:[NSArray arrayWithObject:_revealVC] animated:true];
Hope it will help you
Here you will get Split View you are looking for Click Here

Facebook Like Notification SubView iOS

I would like to create a subview which loads notifications similar to Facebook in its iOS app. Does anyone know how to build that?
Thanks!
Something like that:
http://www.techarp.com/article/Apple/Facebook_Notifications/facebook.jpg
I suggest you to use a UIPopoverController.
UIViewController *viewController = [[UIViewController alloc] initWithNibName:#"UIViewControllerNibName" bundle:nil];
viewController.delegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navController];
navController.contentSizeForViewInPopover = CGSizeMake(400, 200);
viewController.contentSizeForViewInPopover = CGSizeMake(400, 200);
poopover.delegate = self;
CGRect rect = CGRectMake(0, 0, yourWidth, yourHeight);
[popover presentPopoverFromRect:locRect inView:parentView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:TRUE];
viewController is the UIViewController inside the popover, and there you can add, for example, a UITableView to show notifications. UIPopoverController is responsible of showing the popup view. Of course in presentPopoverFromRect: method you have to pass the frame the popover anchors to, the view in which present the popover, the arrow directions allowed and the animate flag in order to show the popover in an animated manner. Finally, with delegation you can communicate to the class that is allocing the popover (self.delegate = self).

How do I load a popover from a view controller in storyboard programatically.

I'm loading a popover from a collection view cell when the user taps on a button. I have managed to get the popover to work but I dont know how to load a view controller that I set up in storyboards.
Here is the code that gets me a popover. How can I get it to load a view controller from the storyboard?
self.popoverContent = [[PopOverViewController alloc]initWithNibName:#"UpcomingCells" bundle:nil];
UIView *popoverView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];
[popoverView setBackgroundColor:[UIColor colorWithRed:224/256.0 green:45/256.0 blue:117/256.0 alpha:1.0]];
self.popoverContent.view = popoverView;
self.popoverContent.contentSizeForViewInPopover = CGSizeMake(200, 300);
self.contactPopover =[[UIPopoverController alloc] initWithContentViewController:self.popoverContent];
[self.contactPopover presentPopoverFromRect:self.remindButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES ];
[self.contactPopover setDelegate:self];
The docs are pretty clear on this, you should use
-instantiateViewControllerWithIdentifier:;
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIStoryboard_Class/Reference/Reference.html
So assuming that you need to load your viewController into self.popOverContent, you do
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:#"nameOfStoryboard"
bundle:nil];
self.popoverContent = [storyBoard instantiateViewControllerWithIdentifier:#"nameOfViewController"];
Just replace nameOfViewController and nameOfStoryboard with actual names ;)
EDIT:
the storyboard name is just the name of your stoyboard-file, minus the extension.
so for "myStoryboard.storyboard" you would simply use "myStoryboard".
Also you need to set a stoyboard-Identifier for your viewController. Its called stryboard-id, and its right below where you set the class name for your viewController, in the identity-inspector.

Changing size of modal dialog ios

How to I change the size of modal dialog? Why is this not working?
SlingDialogViewController *slingDialog = [[SlingDialogViewController alloc] init];
slingDialog.modalPresentationStyle = UIModalPresentationFormSheet;
slingDialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
slingDialog.view.superview.frame = CGRectMake(0, 0, 900, 700);
[self presentModalViewController:slingDialog animated:YES];
Do this:
SlingDialogViewController *slingDialog = [[SlingDialogViewController alloc] init];
slingDialog.modalPresentationStyle = UIModalPresentationFormSheet;
slingDialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:navController animated:YES completion:nil];
slingDialog.view.superview.frame = CGRectMake(0, 0, 900, 700);
slingDialog.view.superview.center = self.view.center;
It's important to call presentViewController:animated:completion first, from my experience at least.
The modal controllers in iOS have fixed sizes. I don't recommend trying to change them, it never works reliably.
A workaround is to implement it by yourself. A modal (presented) controller is a very simple functionality:
A view overlapping your presenting controller, so that it can't be clicked (and it is dimming the contents to make them look backgroundish)
A child view controller (and its view) added to your controller.

Resources