It is possible open Iphone Mail application without compose new message?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"mailto:%#?subject=My Subject", _recipient]]];
This code not suitable for me.
I need just open mail application on main screen.
Thanks
P.S Sorry for my English ))
-(void) EmailMethod
{
MFMailComposeViewController *picker=[[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;
[picker setToRecipients:#"mailid#mymail.com"];
[picker setSubject:#"Place your subject of mail here."];
[picker setMessageBody:#"Place your body of mail here." isHTML:YES];
[self presentModalViewController:picker animated:YES];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
switch (result)
{
case MFMailComposeResultCancelled:
UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:#"Canceled !!"
message:#"Mail sending cancelled." delegate:nil
cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[ErrorAlert show];
[ErrorAlert release];
break;
case MFMailComposeResultSaved:
UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:#"Saved"
message:#"Mail saved to Drafts." delegate:nil
cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[ErrorAlert show];
[ErrorAlert release];
break;
case MFMailComposeResultSent:
UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:#"Email Sent"
message:#"Thank you for recommending us to your friends via Email."
delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[ErrorAlert show];
[ErrorAlert release];
break;
case MFMailComposeResultFailed:
UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:#"Error !!"
message:#"Failed to send mail." delegate:nil
cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[ErrorAlert show];
[ErrorAlert release];
break;
default:
UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:#"Error !!"
message:#"Failed to send mail." delegate:nil
cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[ErrorAlert show];
[ErrorAlert release];
break;
}
[self becomeFirstResponder];
[self dismissModalViewControllerAnimated:YES];
}
Related
Im trying to put the text from a textfield into a UIAlertView, but it's not shown. It is just showing blank.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Kik" message:self.kik.text delegate:self cancelButtonTitle:#"Got it!" otherButtonTitles: nil];
[alert show];
You should try,
if ( [self.kik.text length])
{
UIAlertView *alert = [UIAlertView alloc]initWithTitle:#"Kik" message:[NSString stringWithFormat:#"%#",self.kik.text] delegate:self cancelButtonTitle:#"Got it!" otherButtonTitles: nil];
[alert show];
}
else
{
UIAlertView *alert = [UIAlertView alloc]initWithTitle:#"Kik" message:#"Please enter a valid string" delegate:self cancelButtonTitle:#"Got it!" otherButtonTitles: nil];
[alert show];
}
Check..
I am receiving this error when trying to post an image to Twitter using the following code, cannot think what I am doing wrong any ideas for how to solve?;
- (void)PostToTwitter
{
UIImage* pxImage = [[self GetResultImage] retain];
TWTweetComposeViewController *twitter = [[[TWTweetComposeViewController alloc] init] autorelease];
[twitter setInitialText:#"Twitter Pic"];
[twitter addImage:pxImage];
FaceAppDelegate* app = (FaceAppDelegate*)[[UIApplication sharedApplication] delegate];
[app.mainCtrl presentViewController:twitter animated:YES completion:NULL];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult res)
{
if(res == TWTweetComposeViewControllerResultDone)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Success" message:#"You have posted successfully." delegate:self cancelButtonTitle:#"Close" otherButtonTitles: nil];
[alert show];
[alert release];
}
else if(res == TWTweetComposeViewControllerResultCancelled)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Cancelled" message:#"You have cancelled posting to Twitter." delegate:NULL cancelButtonTitle:#"Close" otherButtonTitles: nil];
[alert show];
[alert release];
}
[app.mainCtrl dismissModalViewControllerAnimated:YES];
};
[pxImage release];
}
I think, that your view isn't presented. Try to use app.window.rootViewController, not property mainContr.
I want to show alert when values is null i have titleCategory if it has value null then it should show alert
NSString*test=titleCategory;
if ([titleCategory isEqualToString:nil])
{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Alert" message:#"Select Category " delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
FirstViewController*targetController=[[FirstViewController alloc]init];
[self.navigationController pushViewController:targetController animated:YES];
}
if(test == nil)
{
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:#"" message:#"Test is null" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil] autorelease];
[alert show];
}
Do this:
if (!(titleCategory.length > 0) || titleCategory == nil )
{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Alert" message:#"Select Category " delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
FirstViewController*targetController=[[FirstViewController alloc]init];
[self.navigationController pushViewController:targetController animated:YES];
[targetController release]; // if not ARC
}
Please Use this code:
if([titleCategory.text isKindOfClass:[NSNull class]]){
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Alert" message:#"Select
Category " delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else{
FirstViewController*targetController=[[FirstViewController alloc]init];
[self.navigationController pushViewController:targetController animated:YES];
[targetController release]; // if not ARC
}
thanks in advance every time I call to create an in app SMS i get the following error...
Application tried to push a nil view controller on target .
This is the code I have that worked in OS 4 SDK...
MFMailComposeViewController *MailController;
MFMessageComposeViewController *SMScontroller;
NSError *error;
NSString *EmailMessage;
NSString *SubjectMessage;
-(IBAction)sendInAppSMS
{
if([MFMessageComposeViewController canSendText])
{
SMScontroller = [[MFMessageComposeViewController alloc] init];
SMScontroller.messageComposeDelegate = self;
NSString *MessageString = #"Hello";
SMScontroller.body = MessageString;
SMScontroller.navigationBar.tintColor = [UIColor blackColor];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
[self presentModalViewController:SMScontroller animated:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
}
else{
// alertView to tell user to setup a mail account.
NSString *message = [[NSString alloc] initWithFormat:#"To use this feature, you need to have an iPhone with SMS abilities."];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"SMS Account Not Detected" message:message delegate:nil cancelButtonTitle:#"Understood" otherButtonTitles:nil];
[alert show];
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"I Like It" message:#"User cancelled sending the SMS"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
break;
case MessageComposeResultFailed:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"I Like It" message:#"Error occured while sending the SMS"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
break;
case MessageComposeResultSent:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"I Like It" message:#"SMS sent successfully..!"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
I believe if you are running this in the simulator you'll get the error since it doesn't have sms. I get the same error in simulator but if i connect to my phone it works fine.
I used the below code to add textfield in UIAlertView. It works fine in Simulator(iOS SDK 5.0) but when i install in device(iOS 4.0.1) i get "Unrecognized selector sent to instance error"
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Enter your name" message:nil delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
alert.tag = 9001;
[alert show];
[alert release];
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:#"My Test Alert" message:#"what do you want" delegate:nil cancelButtonTitle:#"tell me" otherButtonTitles:#"Cancel", nil];
[myAlert addTextFieldWithValue:#"nothing" label:#"say something"];
UITextField * aTextFld = [myAlert textFieldAtIndex: 0];
aTextFld.clearButtonMode = UITextFieldViewModeWhileEditing;
aTextFld.autocorrectionType = UITextAutocorrectionTypeNo;
[myAlert show];
[myAlert release];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Hello!" message:#"Please enter your name:" delegate:self cancelButtonTitle:#"Continue" otherButtonTitles:nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * alertTextField = [alert textFieldAtIndex:0];
alertTextField.keyboardType = UIKeyboardTypeNumberPad;
alertTextField.placeholder = #"Enter your name";
[alert show];
[alert release];
Include the library from here: http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html
Try to use the below code:
AlertPrompt *prompt = [AlertPrompt alloc];
prompt.tag = 100;
prompt = [prompt initWithTitle:#"Enter a name" message:#" " delegate:self cancelButtonTitle:#"Cancel" okButtonTitle:#"Save"];
[prompt show];
[prompt release];