iPad center custom modal view - ipad

I have an application with custom modal view controller and this controller is inside navigation controller here is my code:
CalendarViewController *calendarViewController = [[CalendarViewController alloc] initWithNibName:#"CalendarViewController" bundle:nil];
[calendarViewController setDelegate:self];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:calendarViewController];
[navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
[navigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:navigationController animated:YES];
navigationController.view.superview.frame = CGRectMake(0, 0, 630, 555);
navigationController.view.superview.center = self.view.center;
Problem is that this navigation controller is not center on screen. Location of this screen is right side of ipad. Is there a solution how center this custom controller. Thanks a lot.

Related

navigation controller without using story boards

SecondViewController *testAppViewController2Obj =[[SecondViewController alloc]initWithNibName:#"TestAppViewController2" bundle:nil];
[self.navigationController pushViewController:testAppViewController2Obj animated:YES];
ContainerViewController *container = [[ContainerViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:container];
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 65)];
container.navigationItem.title = #"Frames";
self.window.rootViewController = nav;
i hope it works
In order to push a new view controller you should first create a view controller, VC1, link it with a navigation controller and then link the navigation controller to the rootViewController in the AppDelegate
#AppDelegate
FirstViewController *VC1 = [FirstViewController new];
UINavigationController *nVC = [UINavigationController alloc] initWithRootViewController:VC1];
self.window.rootViewController = nVC;
Then when VC1 gets pushed, you can create another view controller and push it like this:
#Now in VC1
SecondViewController *VC2 = [SecondViewController new];
[self.navigationController pushViewController:VC2 animated:YES];

How do I make the flip animation on a modal view on the iPad transparent in the background?

How do I make my flip animation transparent so the view behind it is shown through?
Here's some of my code:
EditInfoViewController *editController = [[EditInfoViewController alloc] initWithNibName:#"EditInfoViewController" bundle:nil];
editController.delegate = self;
UINavigationController *editNavController = [[UINavigationController alloc] initWithRootViewController:editController];
editNavController.modalPresentationStyle = UIModalPresentationCurrentContext;
editNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController presentModalViewController:editNavController animated:YES];
A picture is worth 1000 words (this was taken during the flip animation):

Keep popovercontentsize constant for all views in navigationcontroller

When I pass my UINavigationController to UIPopOver and set its popOverContentSize property, it remains in effect for only first view. When I navigate to next view, the popOverContent size again expands to full view which is unwanted. How can I restrict the constant size of popOver for all views in navigation controller?
- (void)selectTextStyle:(id)sender {
DJTextStyleMasterViewController *textStyle = [[DJTextStyleMasterViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:textStyle];
UIPopoverController *popOver = [[UIPopoverController alloc]
initWithContentViewController:self.navController];
[popOver setDelegate:self];
[popOver setPopoverContentSize:CGSizeMake(320, 400)];
[popOver presentPopoverFromBarButtonItem:self.textStyleButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[textStyle release];
}
within the first view controller in the popover controller you could use this method:
[self setContentSizeForViewInPopover:CGSizeMake(320, 400)];
Then the view of the popover (if it isn't manually modified) should be the same also for the next view controller.

modalPresentationStyle not working in modal view in iOS5

I want to display a popup window in iPad using the UIView's presentModalViewController method in iOS5.
Even though I set the modalPresentationStyle to UIModalPresentationFormSheet, it only displays as full frame size.
I used the same code in iOS4 before, and it can display as a popup window. How to fix it in iOS5?
DetailViewController *d = [[DetailViewController alloc] initWithNibName:nil bundle:nil];
self.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:d animated:YES];
Thanks.
Have you try
d.modalPresentationStyle = UIModalPresentationFormSheet;
instead of
self.modalPresentationStyle = UIModalPresentationFormSheet;
In iOS5, the modal view should be used as below.
DetailViewController *d = [[DetailViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:d];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:navigationController animated:YES];

Can i use navigation for only the small view?

If i have a landscape view of 300/200 in an iPad, i want to use navigation for only the small view, is that possible? If yes, an example will be really helpfull
What about this:
MainController *controller = [[MainController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
[controller release];
[self.navigationController presentModalViewController:navController animated:YES];
navController.view.superview.frame = CGRectMake(0, 0, 300, 300);
[navController release];
Hope this will help you

Resources