IBActions are not working in another viewcontroller - iphone

i have created a project which has different xib viewcontrollers.In first view am selecting an image through picker controller and am displaying it in the secondviewcontroller.In secondview controller i have some buttons and i have given some IBActions to them.Here starts my problem that am successfully displaying the image in secondviewcontorller but when i tap on button in that viewcontroller app is terminating and the debugger showing the error message as program terminated due to uncaught exception
Here is the code:
To select the pic through pickercontroller in first view
-(IBAction)btnChoosePicClicked {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker=[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else
{
UIAlertView *alert =[[UIAlertView alloc]initWithTitle:#"Error accessing photo library" message:#"Device does not support a photo library" delegate:nil cancelButtonTitle:#"Drat!" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
displaying in the second view and assigning the actions .h file
#interface editScreen : UIViewController{
IBOutlet UIButton *btnRotate;
IBOutlet UIButton *btnLibrary;
IBOutlet UIImageView *imgView;
int RotateAngle;
}
-(void)setImage:(UIImage *)img;
-(IBAction)btnLibraryClicked;
-(IBAction)RotateImage;
#end
.m file
#implementation editScreen
-(void)setImage:(UIImage *)img
{
[imgView setImage:img];
imgView.userInteractionEnabled = YES;
}
-(IBAction)RotateImage
{
CGAffineTransform transform = imgView.transform;
transform = CGAffineTransformRotate(transform, M_PI/2);
imgView.transform=transform;
RotateAngle+=90;
if(RotateAngle>=360)
{
RotateAngle-=360;
}
//imageview.transform = CGAffineTransformScale(imageview.transform, -1.0, 1.0);
}
-(IBAction)btnLibraryClicked {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker=[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
// NSFileHandle *fileHandle = [[NSFileHandle alloc]initWithFileDescript
}
else
{
UIAlertView *alert =[[UIAlertView alloc]initWithTitle:#"Error accessing photo library" message:#"Device does not support a photo library" delegate:nil cancelButtonTitle:#"Drat!" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
I dont know whats wrong with my code please help me.I have given appropriate connections in IB..
Thanks in Advance

For some UIKit class, his delegate has some methods which must be implemented.
For example, UIImagePickerViewControllerDelegate must implement following methods:
– imagePickerController:didFinishPickingMediaWithInfo:
– imagePickerControllerDidCancel:
For your above codes, I don't know whether these methods are implemented or not. Hope these information can help you.

Related

How to dimiss a UIAlertView when tapping anywhere on the window

I am opening alert popup on click button which is working fine the code is
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"PopUP Title"
message:#"This is pop up window/ Alert"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
UIImageView *tempImageView=[[UIImageView alloc]initWithFrame:CGRectMake(20,20,50,50)];
tempImageView.image=[UIImage imageNamed:#"abc.png"];
[alert addSubView:tempImageView]
[alert show];
the alert box is closing on click of Ok button ,i don't want it, i wants to colse the alert box on click of any where on window .
please help me.
It sounds like you are essentially trying to recreate a "Toast" on iOS. Good news, someone has already done that. See this project.
Edit: Don't want to use iToast. I like your style, less code it is. Here is what I come up with. It would seem obvious as others have said that the only way to overcome the modal nature of the UIAlertView is to add a superview to handle touch events. But you don't have to do that manually every time, consider subclassing UIAlertView. Try something like this:
Edit: #wagashi, Thanks for accepting my answer, and thanks for the heads up about setFrame: being a good place to adjust the size. Your code does make a very toast-like little alert, however when I tried it I found that if the message was to long the view seemed to fall apart. So I have modified setFrame: to simply reduce the size of the alert by about the size of one button, and to remain centered on the screen. So that the class accurately answers the question title "iOS How to dismiss UIAlertView with one tap anywhere?"
NoButtonAlertView.h
#import <UIKit/UIKit.h>
#interface _NoButtonAlertViewCover : UIView
#property (nonatomic,assign) UIAlertView *delegate;
#end
#interface NoButtonAlertView : UIAlertView
-(id)initWithTitle:(NSString *)title message:(NSString *)message;
#end
NoButtonAlertView.m
#import "NoButtonAlertView.h"
#implementation _NoButtonAlertViewCover
#synthesize delegate = _delegate;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[self removeFromSuperview];
[_delegate dismissWithClickedButtonIndex:0 animated:YES];
}
#end
#implementation NoButtonAlertView
-(void)show{
[super show];
_NoButtonAlertViewCover *cover = [[_NoButtonAlertViewCover alloc] initWithFrame:[UIScreen mainScreen].bounds];
cover.userInteractionEnabled = YES;
cover.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:.01];
cover.delegate = self;
[self.superview addSubview:cover];
}
-(id)initWithTitle:(NSString *)title message:(NSString *)message{
if ((self = [super initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil])){
}
return self;
}
- (void)setFrame:(CGRect)rect {
// Called multiple times, 4 of those times count, so to reduce height by 40
rect.size.height -= 10;
self.center = self.superview.center;
[super setFrame:rect];
}
#end
With this simple UIAlertView subclass and its UIView subclass for a cover, you can use it as simply as you would a standard UIAlertView. Like so:
NoButtonAlertView *alert = [[NoButtonAlertView alloc] initWithTitle:#"Hello" message:#"I am the very model of a modern major general; I'm information, vegitable, animal, and mineral."];
[alert show];
Will yield:

objective C unable to switch views after scanning a QR code using ZBar

I am developping an App using XCode 4.2 that detects a QR code.
I am trying to make a switch view after QR code detection but it is not working at all
here is the code am using :
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
// ADD: get the decode results
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
break;
NSString *string=symbol.data;
NSString *string2=#"1234";
if ([string isEqualToString:string2]) {
//this is the part that is not working : it doesn t load the AboutView at all
AboutView *about = [[AboutView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:about animated:YES];
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"This is not a recognized QR code!"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
}
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
}
thanks
The issue is that the reader is the presented view controller in zbar's example code
-(void)presentReaderInViewController:(UIViewController*)vc
and you are treating self as if it is presented
You should use reader to present your AboutView and only dismiss reader in the else block
if ([string isEqualToString:string2]) {
//this is the part that is not working : it doesn t load the AboutView at all
AboutView *about = [[AboutView alloc] initWithNibName:nil bundle:nil];
[reader presentModalViewController:about animated:YES];
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"This is not a recognized QR code!"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
}
You might also want to wait to dismiss reader in the delegate method of your alert view (create a soft reference and dismiss that... myReader = reader; when you set up the alertview)
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
[myReader dismissModalViewControllerAnimated: YES];
}

Why does my camera interface act weird when I use UIImagePickerController?

In my app I want the user to be able to take a picture or use one from the photo library. When the user clicks the button I made a alert view pops up at the user can choose between taking a new photo or one from the photo library. Here is the code I've used:
- (void)PictureAlert:(id)sender {
UIAlertView *AlertDialog;
// Setting up AlertDialog.
AlertDialog = [[UIAlertView alloc] initWithTitle:nil
message:nil
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"Choose From Library", #"Take New Picture", nil];
[AlertDialog show]; }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *ButtonTitle = [alertView buttonTitleAtIndex:buttonIndex];
if ([ButtonTitle isEqualToString:#"Choose From Library"]) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
// Pick photo.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
} else if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
// Setting up AlertDialog.
UIAlertView *AlertDialog;
AlertDialog = [[UIAlertView alloc] initWithTitle:#"Error accessing photo library"
message:#"Device does not support a photo library"
delegate:self
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[AlertDialog show];
}
} else if ([ButtonTitle isEqualToString:#"Take New Picture"]) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
// Take new photo.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.wantsFullScreenLayout = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
} else if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
// Setting up AlertDialog.
UIAlertView *AlertDialog;
AlertDialog = [[UIAlertView alloc] initWithTitle:#"Error accessing camera"
message:#"Device does not support a camera"
delegate:self
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[AlertDialog show];
}
}
}
The problem is that if the user wants to take a new picture the camera interface pops up, and then if you rotate the device the interface looks like this:
And then when the user rotate it back it suddenly looks like this:
A little side problem is that the camera takes a long time to load.
Any thoughts would be appreciated :)
A few things you might want to consider:
Setting the wantsFullScreenLayout property to YES will cause the view to ignore the status bar. But since you are using the default camera controls, the status bar hides automatically. This is the most likely cause for the 20 pixel grey area on the bottom of the image.
The default camera controls are designed to be in portrait mode only. Since your first image looks like you somehow rotated the screen, you should look into your code (probably shouldAutoRotate) and see why you are rotating the view like that. This should fix the problem of the zoom you are getting in your landscape picture.
You will have memory leaks if you create a UIImagePickerController, present it, and then have no reference to it to release it later. I would recommend setting the UIImagePickerController in the interface, and setting it up in the viewDidLoad method. Try:
.h
#interface yourView:UIViewController <UIImagePickerControllerDelegate> {
UIImagePickerController * picker;
}
.m
- (void)dealloc; {
[picker release];
[super dealloc];
}
- (void)viewDidLoad; {
[super viewDidLoad];
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; {
NSString *ButtonTitle = [alertView buttonTitleAtIndex:buttonIndex];
if([ButtonTitle isEqualToString:#"Choose From Library"]){
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
}
else{
// Setting up AlertDialog.
UIAlertView *AlertDialog;
AlertDialog = [[UIAlertView alloc] initWithTitle:#"Error accessing camera"
message:#"Device does not support a camera"
delegate:self
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[AlertDialog show];
[AlertDialog release];
}
}
else if([ButtonTitle isEqualToString:#"Take New Picture"]){
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}
else{
// Setting up AlertDialog.
UIAlertView *AlertDialog;
AlertDialog = [[UIAlertView alloc] initWithTitle:#"Error accessing camera"
message:#"Device does not support a camera"
delegate:self
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[AlertDialog show];
[AlertDialog release];
}
}
}
This should clean-up the memory leaks, and improve the load time. Hope that Helps!
Some time its happened if you are using a old generation iphone that have current os for example you are having iphone 3G and you update its ios to ios5 then some of the app you installed can behave differently you can check your app to another device for rectify your problem.
Make sure you set the view controller hierarchy, with mainWindow.rootViewController and [vc addChildViewController:]. This propagates orientation information down to where you need it.
It looks like for my project this was happening because you have not written the shouldAutoRotateToInterface: method in your root view controller. The rotate message propagates all the way down to the root view controller's shouldAutoRotateToInterface delegate when UIImagePickerController is called. Your method should look like this:
- (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
When I upgraded my project to iOS 5, I borrowed my root view controller from an iOS 3 project. iOS 3 did not automatically write this method in view controller classes Try it out and let me know.

IOS development, using UITabBarController and UIImagePickerController, How to go from one tab to another?

I can't seem to find an answer for this, or maybe can't understand the things people wrote over the web...
I have a UITabBar with 3 tubs.
One of the tabs is a UIImagePickerController. This TabBar Item is connected to a view controller that i set also as the delegate for the Image picker (camera).
I want that then someone take a photo or press cancel, The first TabBar item will be choosen (don't want to stay in the TabBar that holds the camera).
My question is, How do I "talk" with the TabBar controller from a view controller that is in one of the TabBar items?
my code in the TakePhotoViewController.m file that is in the 3rd TabBer item and i want to go the first item.
-(void) viewWillAppear:(BOOL)animated{
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsEditing = NO;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imgPicker animated:YES];
}
and the delegate methods:
#pragma mark -
#pragma mark - UIImagePicker delegate methods
//saving the image that was taken
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
// Save image
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);
[picker release];
}
//alerting the user if the images was saved or not
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
UIAlertView *alert;
// Unable to save the image
if (error)
alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
else // All is well
alert = [[UIAlertView alloc] initWithTitle:#"Success"
message:#"Image saved to Photo Album."
delegate:self cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
//if user is cancelling the camera
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[picker release];
}
Thank you very much,
Erez
[self.tabBarController setSelectedIndex:1];
You can pass your desired tab index value instead of 1.

Exception in iPhone app : Modal transition is already in progress

I have what I believe is a fairly simple application at the moment based on a few tutorials cobbled together. I'm using XCode 3.2.3 in OSX 10.6.4. It started as a standard iPhone "Window Based Application". Using interface builder I have added a Tab Bar Controller using the O'Reilly video tutorial here:
http://broadcast.oreilly.com/2009/06/tab-bars-and-navigation-bars-t.html
In the first Tab I have a standard UIView with two buttons. Both call the same function to display a UIImagePickerController:
-(IBAction) btnPhotoClicked:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
if((UIButton *)sender == btnChoosePhoto)
{
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
I am running the code inside an emulator so only ever click the button called Choose Photo. When the dialogue is released with a photo chosen this function runs:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *mediaUrl;
mediaUrl = (NSURL *)[info valueForKey:UIImagePickerControllerMediaURL];
if (mediaUrl == nil)
{
imagePuzzle = (UIImage *) [info valueForKey:UIImagePickerControllerEditedImage];
if(imagePuzzle == nil)
{
//--- Original Image was selected ---
imagePuzzle = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];
}
else {
//--- Get the edited image ---
//--- If it was successful the above valueForKey:UIImagePickerControllerEditedImage
//--- would have assigned it already.
}
}
else {
//--- Muppet selected a video
}
// Animate the picker window going away
[picker dismissModalViewControllerAnimated:YES];
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.delegate = self;
[self presentModalViewController:imageViewController animated:YES];
[imageViewController release];
}
This is where my problem lies. I've tried many different hacks and iterations but the above code is the simplest to present the problem. When the imageViewController is displayed as a modal dialogue the following exception is thrown:
2010-07-09 15:29:29.667 Golovomka[15183:207] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal
transition from <NewViewController: 0x5915f80> to <ImageViewController: 0x594a350>
while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear
to know the current transition has completed'
How do I cure this? I have tried delays and other tricks but do not really understand how I'm supposed to use viewDidAppear or viewDidDisappear to help me. Also of note is that a very basic application with one view loading the picker then displaying another view with the image in does not produce the error. Any help gratefully received.
To address the specific issue described here, you could add the viewDidAppear method in your class:
-(void)viewDidAppear:(BOOL)animated
{
if (/*just visited ImagePicker*/)
{
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.delegate = self;
[self presentModalViewController:imageViewController animated:YES];
[imageViewController release];
}
}
Remove those lines from below your call:
[picker dismissModalViewControllerAnimated:YES];
So, whenever your class self appears (is displayed), it will call viewDidAppear... Since this most likely isn't really what you want all the time, you could add some variables to set/clear that defines whether or not to immediately present the imageViewController when self is displayed. Something like "If coming from image picker, show the imageViewController, otherwise do nothing".
That said, imho, pushing modal views is should generally be done in response to a user action and I would maybe rethink the user experience here - e.g. add a subview instead of pushing a modal view which you could do where your currently have the code - but if you're just playing around with some tutorials that should solve the NSInternalInconsistencyException. :) Cheers!
In iOS 5.0 and above you can use
[self dismissViewControllerAnimated:YES completion:^{
//present another modal view controller here
}];
I ran into this issue quite a few times. I recently started using this simple fix:
When I am going to present a new modal view controller immediately after dismissing another modal view controller, I simply dismiss the first one with argument NO in dismissModalViewControllerAnimated:.
Since the second view is presented with an animation, you hardly notice that the first one goes away fast. And you never get the transitions conflict.
I was having the same problem when i wanted to present an MFMailComposeViewController immediately after dismissing the UIImagePickerController. Heres what i did:
I removed the [imagePicker release]; statement from where i was presenting the image picker and put it in didFinishPickingMedia callback.
I used [self performSelector:#selector(presentMailComposer:) withObject:image afterDelay:1.0f];
Here's my code:
Displaying Image Picker
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
NSArray *media = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
if ([media containsObject:(NSString*)kUTTypeImage] == YES) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[picker setMediaTypes:[NSArray arrayWithObject:(NSString *)kUTTypeImage]];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
//[picker release];
}
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Unavailable!"
message:#"Could not open the Photo Library."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
Image Picker Delegate Callback - didFinishPickingMedia
NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
UIImage *photoTaken = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
//Save Photo to library only if it wasnt already saved i.e. its just been taken
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(photoTaken, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);
}
//Pull up MFMailComposeView Controller
[self performSelector:#selector(composeMailWithPhoto:) withObject:photoTaken afterDelay:1.0f];
}
[picker dismissModalViewControllerAnimated:YES];
[picker release];
Display Mail Composer View
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init];
mailPicker.mailComposeDelegate = self;
// Fill out the email fields and Attach photograph to mail
static NSString *imageType = #"image/jpeg";
NSString *imageName = [NSString stringWithString:#"MyCoffeeCup.jpg"];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[mailPicker addAttachmentData:imageData mimeType:imageType fileName:imageName];
[mailPicker setToRecipients:[NSArray arrayWithObject:#"hello#xische.com"]];
[self presentModalViewController:mailPicker animated:YES];
//[self.navigationController pushViewController:mailPicker animated:YES];
[mailPicker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Unavailable!"
message:#"This device cannot send emails."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}