I need help in problem. I want to change modalPresentationStyle dynamicaly when it open, after rotating event.
I write this for create modalView
ZUITableViewController *ivc = [[ZUITableViewController alloc] init];
ivc.delegate = self;
_modalIsShowing = TRUE;
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:ivc];
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
{
nc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
nc.modalPresentationStyle = UIModalPresentationFormSheet;
}
else{
nc.modalPresentationStyle = UIModalPresentationFullScreen;
}
[self presentModalViewController:nc animated:YES];
[ivc release];
[nc release];
Scrap the if statement UIModalPresentationPageSheet behaves properly to start with.
ZUITableViewController *ivc = [[ZUITableViewController alloc] init];
ivc.delegate = self;
_modalIsShowing = TRUE;
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:ivc];
nc.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:nc animated:YES];
[ivc release];
[nc release];
Related
I am using SWRevealViewController in my iPhone app.
After successful login I am creating SWRevealViewController from my viewcontroller.
profileView *frontViewController = [[profileView alloc] init];
RearViewController *rearViewController = [[RearViewController alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController];
SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;
frontViewController.user_id = [defaults objectForKey:#"userid"];
appDelegate.user_id = [defaults objectForKey:#"userid"];
[self.navigationController pushViewController:revealController animated:YES];
Now I want to logout and come back to viewcontroller. I tried poptoRootviewcontroller, but not working. How to do this ?
Try this - Call from your front/rear viewController:
[self.revealViewController.navigationController popViewControllerAnimated:YES];
Try this code on your action:
ViewController *vc = [[ViewController alloc]init];
UINavigationController *nvc = [[UINavigationController alloc]initWithRootViewController:vc];
[reveal pushFrontViewController:nvc animated:YES];
I have this code
-(void)didPressButton:(int)tag
{
// Preventivi?
if (tag == 0)
{
if (addPrev == nil)
addPrev = [[avvAddPreventivoViewController alloc] init];
addPrev.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addPrev];
navigationController.navigationBarHidden = NO;
[[navigationController navigationBar] setBarStyle:UIBarStyleBlack];
[self presentViewController:navigationController animated:YES completion:nil];
addPrev = nil;
}
}
When I show up the addPrev the memory increases, when show off the memory does not release.
When the addPrev dismiss it fires a protocol methos, didCancel. I intercept it and release addPrev:
-(void)didCancel
{
[self dismissViewControllerAnimated:YES completion:nil];
addPrev = nil;
}
Niling also the navigation controller improves drastically the memory allocation.
Also, be careful to deallocate what you can deallocate in the dealloc of the pushed controller.
-(void)didPressButton:(int)tag
{
// Preventivi?
if (tag == 0)
{
if (addPrev == nil)
addPrev = [[avvAddPreventivoViewController alloc] init];
addPrev.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addPrev];
navigationController.navigationBarHidden = NO;
[[navigationController navigationBar] setBarStyle:UIBarStyleBlack];
[self presentViewController:navigationController animated:YES completion:nil];
addPrev = nil;
navigationController = nil;
}
}
I used the following code to view the event. But navigation bar doesn't visible.
EKEventViewController *addController = [[EKEventViewController alloc] initWithNibName:nil bundle:nil];
addController.event = self.event;
addController.allowsEditing = YES;
addController.allowsCalendarPreview = YES;
[self.navigationController presentViewController:addController animated:YES completion:nil];
with Present viewcontroller you need to Add sepreated NavigationController for UIViewcontroller like:-
EKEventViewController *addController = [[EKEventViewController alloc] initWithNibName:#"EKEventViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:addController];
addController.event = self.event;
addController.allowsEditing = YES;
addController.allowsCalendarPreview = YES;
if ([self respondsToSelector:#selector(presentViewController:animated:completion:)])
{
[self presentViewController:navController animated:YES completion:nil];
}
else
{
[self presentModalViewController:navController animated:YES];
}
I have implemented the KKLockscreen view controller and is working well within the in-app settings controller. Able to set passcode and change them as well.
I am having problem to call he lock screen view from appdelegate. I have added delegate .h file and imported the view controller in .m file. still it's not calling the lockscreen. any help?
below is my code.
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) {
KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil];
vc.mode = KKPasscodeModeEnter;
vc.delegate = self;
dispatch_async(dispatch_get_main_queue(),^ {
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
nav.modalPresentationStyle = UIModalPresentationFormSheet;
nav.navigationBar.barStyle = UIBarStyleBlack;
nav.navigationBar.opaque = NO;
} else {
nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor;
nav.navigationBar.translucent = _navigationController.navigationBar.translucent;
nav.navigationBar.opaque = _navigationController.navigationBar.opaque;
nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle;
}
[_navigationController presentModalViewController:nav animated:NO];
});
}
}
i have checked it with my code and it is working ,ya but you have not give nib name here in this line and i have given may be that why it is not displaying your view.
KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]
-(void)applicationDidBecomeActive:(UIApplication *)application {
RootViewController *vc = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
dispatch_async(dispatch_get_main_queue(),^ {
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
nav.modalPresentationStyle = UIModalPresentationFormSheet;
nav.navigationBar.barStyle = UIBarStyleBlack;
nav.navigationBar.opaque = NO;
} else {
nav.navigationBar.tintColor = navigationController.navigationBar.tintColor;
nav.navigationBar.translucent = navigationController.navigationBar.translucent;
nav.navigationBar.opaque = navigationController.navigationBar.opaque;
nav.navigationBar.barStyle = navigationController.navigationBar.barStyle;
}
[navigationController presentModalViewController:nav animated:NO];
});
}
I have UIBarButtomItem that shows popover when pressed:
//add help button
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(#"Help", #"Help") style:UIBarButtonItemStylePlain target:self action:#selector(showInfoBubble:)] autorelease];
infoBubblePopOverVisible = NO;
self.infoBubblePopOverController = nil;
Here is show info bubble:
- (void) showInfoBubble: (id) sender {
[self dismissPopoverControllerExplicitly];
if (self.infoBubblePopOverController == nil) {
InfoBubbleViewController *controller = [[InfoBubbleViewController alloc] initWithNibName:#"InfoBubbleViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
self.infoBubblePopOverController = [[UIPopoverController alloc] initWithContentViewController:navigationController];
[controller release];
[navigationController release];
}
//present popOverController
[self.infoBubblePopOverController presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
infoBubblePopOverVisible = YES;
}
But when presented popover is presented partially covering barbuttomitem:
How can i fix this?