Previous View after dismissModalViewControllerAnimated of email function somehow defect - iphone

i am trying and trying.... but no result yet.
i have a view with a navigationcontroller and -bar. in addition there is a tableview.
if you click on a row, the iphone email function is getting startet by using the email example from apple (MailComposerViewController.h and .m).
it opens and i am able to send or cancel the mail. after that the "dismissModalViewControllerAnimated" methode is dismissing the emailing view. everything looks right, i am in the previous view now, BUT:
when i want to use buttons from the navigationitem or if i want to add rows to the tableview, the app is crashing without any error message.
do i have to set something back or to "remove" something which is still there because of the mailing view?
it's really strange and i am searching now for hours....... :-(
thank you very much in advance!
hopefully someone has an idea.
EDIT:
ok, here i have the code now:
in a tableview which is included in a navcontroller i have following lines to open first a Subclass of UIViewController:
- (IBAction)Action:(id)sender
{
DetailViewController *editViewController = [[DetailViewController alloc] initWithNibName:#"TripDetailViewController" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:editViewController animated:YES];
editViewController.navigationItem.prompt = #"Details";
[editViewController release];
}
in the DetailViewController following action is processed when the user clicks on the button:
- (IBAction)mailTrip:(id)sender {
MailComposerViewController *mailComposer = [[MailComposerViewController alloc] init];
[[[self view] window] addSubview:[mailComposer view]];
[mailComposer showPicker:sender];
}
when i press the related button, the MailComposerViewController pushes up correctly. all functions of the MailComposerViewController are working correct.
but when i send or cancel the mail and the MailComposerViewController disappears, my previous view doesn't work anymore.
in the MailComposerViewController-Example from apple the MailComposerViewController just disappear and the previous view is working fine again.... :-(

ok, i found the stupid simple problem.
the MailComposer-View was after dismissing it still over the previous view.
i did set the propert hidden after dismissing and now it works...
[self dismissModalViewControllerAnimated:YES];
[[self view] setHidden:YES];
but i am really not sure if this is the right way to do it...

Related

How to dismiss the view

I have used the below code to show the view with partial curl effect.
And it works fine but I want to know that how can i dismiss the popoverViewController when touching the curl effect as like in the map application in the iphone.
thanks for any help
UINavigationController *navPop = [[UINavigationController alloc] initWithRootViewController:popoverViewController] ;
[popoverViewController release];
[popoverViewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:navPop animated:YES];
actually i know the code to dismiss the view but , wat i need to know is i want to dismisss it by clicking on the curl effect.. this is wat i would like to know
Use the dismissModalViewControllerAnimated: method.
You are setting modalTransitionStyle of wrong object, I guess. As you are presenting navPop you should set the property to it:
[navPop setModalTransitionStyle:UIModalTransitionStylePartialCurl];
When you would like to dismiss it, just call:
[navPop dismissModalViewControllerAnimated:YES];
And you will see curl effect

How do I launch a modal view from a custom UITabBar?

I've built out the raised-center UITabBar from this GitHub location.
My challenge now is that I can't figure out how to create a modal view that will appear when the button is pressed.
Has anyone used the idev-recipes RaisedCenterTabBar with luck? How did you implement the modal sheet that appears there?
Alternatively, is there a different gitHub project that has a working custom tab bar with a modal sheet?
Thank you!
Here was my solution, it was BY FAR the cleanest way I found to do this... I really hope it helps, I spent hours researching the best ways.
I setup a "UITabBarController" delegate that connects directly to my tab interface built out on my storyboard.
** Don't forget to include the "tabBarController" delegate in your header file
** Notice this callback method is NOT the "didSelectViewController" but rather the "shouldSelectViewController". This method handles the request before the tab is selected and that is exactly what you want so you can STOP the request before it ever happens... This way you don't have to save the current index you are on, pass it around and all that nonsense.
Then I am simply checking what tab WILL be selected (based on the view controller's title.
** Also: this is my code, change it as needed for your code. But the principals should remain. My "performSegueWithIdentifier" is actually a manual segue connected to my tab controller that opens in a modal. This code is working brilliant for me.
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
if([[viewController title] isEqualToString:#"tellvc"])
{
[self performSegueWithIdentifier:#"shareModelViewController" sender:Nil];
return NO;
}
else
{
return YES;
}
}
I have something similar in a program of mine that I'm working on and would be glad to show you how I do it. I have a couple of viewControllers in a TabBar. I create my Plus button in whichever VC I decide will appear first on the screen in ViewDidLoad.
// Create a plus button that appears on the tabBar
UIImage *plusButton = [UIImage imageNamed:#"plusbutton.png"];
UIView *tabBarView = [[self tabBarController] view];
addButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addButton setFrame:CGRectMake(127.0, 432.0, [plusButton size].width, [plusButton size].height)];
[addButton setBackgroundImage:plusButton forState:UIControlStateNormal];
[tabBarView addSubview:addButton];
[addButton addTarget:self action:#selector(scalePicker:) forControlEvents:UIControlEventTouchUpInside];
I make the button a subView of the tabBarController's view. Later on in the implementation of this VC I have a method called scalePicker: which creates and instance of one of my other VC's and presents it modally. Here is the code for that: (note: this is the method that I set as a target for the plus button in the code above)
-(void) scalePicker:(id)sender
{
// create the view scalePicker, set it's title and place it on the top of the view hierarchy
sp = [[ScalePickerVC alloc] init];
[self presentModalViewController:pickerNavController animated:YES];
}
I hope this helps you,
Good Luck!

How come presentModalViewController is not working the second time?

I am using a tab based application that shows a presentModalViewController called "overview" that has 2 buttons on it .
In order to call it I am using the following code in app delegate:
Overview *overview = [[Overview alloc] initWithNibName:#"Overview" bundle:nil];
[self.tabBarController presentModalViewController:overview animated:YES];
When overview shows up, it has a button called that gets clicked and I am using the following code:
-(IBAction) btnLoginPressed{
[self dismissModalViewControllerAnimated:YES]; //get rid of view
Login *login = [[Login alloc] initWithNibName:#"Login" bundle:nil];
[self.tabBarController presentModalViewController:login animated:YES];
[login release];
}
However the login prsentModalViewController never shows up. Can someone explain why and what I can do to show it?
Thanks
When you present a modal view controller, you do it from the view controller currently in the view.
Assuming your second modal display of a view controller is happening in Overview.m change your code to the following:
-(IBAction) btnLoginPressed {
Login *login = [[Login alloc] initWithNibName:#"Login" bundle:nil];
[self presentModalViewController:login animated:YES];
[login release];
}
You don't need to dismiss Overview first, and in fact you shouldn't as it the animations won't work in conjunction with each other.
When you ultimately dismiss login (or however deep you want to go), you send dismissModalViewController:animated: as high up as you need to. To get back to the tab bar's controller use:
[self.tabBarController dismissModalViewController:animated]
It would be well beyond the scope of your question and the time I have to answer but you should take some time and really study the docs on implementing View Controllers. I definitely recommend following Apple's code style guidelines as one suggestion to make your code much more readable (e.g. overviewViewController vs overview). It's also clear you're just learning so keep at it.

ABPersonViewController drawn under the navgation bar

The context:
I am working on an app that maintains a list of contacts along with their record IDs for it's own reference.
When the user needs to change the number associated with a specific contact within the app, I am trying to display the ABPersonViewController so the user can choose the new number from the contact in AB.
The problem:
The problem is that the ABPersonViewController that is opened is starting all the way from the top of the screen as if it does not know that there is a navigation bar on the top.
As a result some of the top part of the ABPersonViewController screen (the top part of the person image and the top part of the name) is underneath the navigation bar.
Ideally i want it to look like this, but not in edit mode: http://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Art/person_view.jpg
Also I wanted to add a "cancel" button to the top right part of the nav bar. Trying to add that as a bar button is not working either.
The code:
this is how I am adding the ABPersonViewController to the navigationController:
ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.personViewDelegate = self;
personViewController.displayedPerson = person;
[self.m_circleNavController pushViewController:personViewController animated:YES];
[personViewController release];
The self here is a UIVIewController.
The m_circleNavController is the UINavigationController to which the UIVIewController belongs.
I tried these 2 ways of showing the person view, but both behave the same way.
[self.m_circleNavController pushViewController:personViewController animated:YES];
[self.navigationController pushViewController:personViewController animated:YES];
I'm not too sure what I am doing wrong, or what is the best way to do it.
I tried a lot of different ways to display it in vain.
The viewcontroller was behaving as though it was starting about 40 pixels above the top edge of the screen.
I was able to fix it in a very weird way finally. In the init function of the viewcontroller I added the following line:
self.view.bounds = CGRectMake(0, -43, 320, 440);
But still no clue as to why it happens this way. I was to close to the deadline to look for a decent solution.
Hello I've been having the same problem as of the new iOS. When this happens on my custom view controllers I have been able to correct it with:
if (self.interfaceOrientation != UIInterfaceOrientationPortrait) { // UI is in landscape position
[self.tableView setContentInset:UIEdgeInsetsMake(32,0,0,0)];
} else { // UI is in portrait position
[self.tableView setContentInset:UIEdgeInsetsMake(44,0,0,0)];
}
But when using the ABPersonViewController I don't quite know how to handle this problem.
Hope someone has an idea...

how can I call a screen with a button action (xcode)?

I am developing a Window Based app for iPhone. I use Interface Builder to build Interface. I want to call a new screen with a Button Action. How can I call the screen with Button action ?
By pushing the new controller onto the top of the stack of windows. For example:
EnterNameController *newEnterNameController = [[EnterNameController alloc] initWithNibName:#"EnterName" bundle:[NSBundle mainBundle]];
[[self navigationController] pushViewController:newEnterNameController animated:YES];
Apple has an extraordinary amount of sample code, and this question (as well as many others) could easily be solved by simply visiting Apple's iPhone dev site.
iPhone Dev Site
If you are using a navigation controller, push it onto the navigation controller's stack, as alamodey suggested.
If you want it to be a modal controller (that is, slide up from the bottom and cover the previous controller's view, like the Bookmarks screen in Safari), present it as a modal view controller:
[self presentModalViewController:myNewController animated:YES];
When you want to bring the old controller back, dismiss the modal view controller. From inside the modal view controller:
[self.parentViewController dismissModalViewControllerAnimated:YES];
If you don't want to do either, just remove the current controller's view from the window and add the new controller's:
UIView * containingView = self.view.superview;
[self.view removeFromSuperview];
[containingView addSubview:myNewController.view];
If you go this route, you may want to look into +[UIView beginAnimations:context:], +[UIView setAnimationTransition:onView:], and +[UIView commitAnimations] (if I recall the method names correctly--check the documentation) to animate the transition. You should almost always animate any switch between screens in iPhone OS.
(work in .m class)
#import "classtocall.h"
- (IBAction)ButtonPressed:(id)sender
{
classtocall *mvc = [[classtocall alloc]initWithNibName:#"classtocall" bundle:nil];
[self presentModalViewController:mvc animated:NO];
}
(for window based application)
define in .h class
- (IBAction)ButtonPressed:(id)sender;
where "classtocall" is the class you want to call.
you just need to download sample applications from XCode help. Try Elements and UIcatalog. There are also other - type 'pushViewController' or 'addSubview' adn 'makeKeyAndVisible' in help and download samples
nextscreenViewController *login = [[self storyboard] instantiateViewControllerWithIdentifier:#"nextscreenidentifier"];
nextscreenidentifier.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: nextscreenidentifier animated: YES];