I have been following a tutorial series and I am trying to learn how to send an email.
I typed in the following line of code but it says it was deprecated in iOS 6.
[self presentModalViewController:picker animated:YES];
What would be the replacement for this code in iOS 6 be and would it work on iOS 5 devices?
That method was deprecated and is replaced by
presentViewController:animated:completion:
But really, that's right at the top within the documentation of presentModalViewController:animated:.
Related
In my app I need to present a view controller. The 6.0 method for presenting a view controller is presentViewController:animated:completion:. I want to support 4.3 also. In 4.3 the method to be called is presentModalViewController:animated:. So I use respondsToSelector: to find out whether the method is supported. But when I compile the app for 6.0 it gives warning message as
presentModalViewController:animated: is deprecated: first deprecated in iOS 6.0
Can anyone know how to get rid of this warning. I also do not have 4.3 device to test whether it works. I need to assume that the code I write should work on 4.3.
if([myViewController respondsToSelector:#selector(presentModalViewController:animated:)]){
[myViewController presentModalViewController:anotherViewController animated:YES];
}else{
[myViewController presentViewController:anotherViewController animated:YES completion:nil];
}
you could make check opposite for respondsToSelector it might help, and this is the way to go actually if you are supporting older versions:)
if ([self respondsToSelector:#selector(presentViewController:animated:completion:)]){
[self presentViewController:anotherViewController animated:YES completion:nil];
} else {
[self presentModalViewController:anotherViewController animated:YES];
}
You can enable / disable warning with pragma into your code, but they are not very friendly to use. And i don't remember the specific pragma for this kind of warning. But some guys here will told you.
By the way you can use a simple
[id performSelector:<#(SEL)#> withObject:<#(id)#>]
will do the trick
I had mistakenly set the deployment target to 6.0. So it was showing the mentioned warning message. No warning message after I changed the deployment target to 4.3(which I need to support). Thanks for the answers!.
I am building a PhoneGap app using Cordova 2.2 for IOS. I am experiencing some bizarre behavior when calling out to a native obj-c plugin I have written to show the MFMessageComposeViewController.
The setup is very simple - I have a tap event attached to a UI element, that when pressed, will make a call to my PhoneGap plugin, pass with it a number and a text message, then show the MFMessageComposeViewController with the parameters pre-populated.
My javascript looks like this:
$(document).bind('deviceready', function(){
$(".theButton").tap(function(){
cordova.exec(function(){}, function() {}, "PhoneGapSms", "SendSms", [db.getItem("profile_sms"), db.getItem("profile_emergency")]);
});
});
And my obj-c code looks like this:
- (void)SendSms:(CDVInvokedUrlCommand*)command
{
CDVInvokedUrlCommand* myCommand = command;
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
NSString* body = [command.arguments objectAtIndex:0];
NSString* toRecipientsString = [command.arguments objectAtIndex:1];
if(body != nil)
picker.body = body;
if(toRecipientsString != nil)
[picker setRecipients:[ toRecipientsString componentsSeparatedByString:#","]];
picker.messageComposeDelegate = self;
[self.viewController presentModalViewController:picker animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[picker release];
}
So, all in all, very simple stuff.
My Problem is this:
When my iPhone is plugged into my Mac and the app is run from XCode, the Message Composer overlay appears great, with my values pre-populated. Image below demonstrating the SMS interface appears fine while plugged into XCode:
When my iPhone is unplugged from my Mac, and the app is run from the spring board, the Overlay slides up, the keyboard begins to slide up, then immediately slides down - making it impossible to type or send the message. This is what it looks like when not attached to the Mac/Xcode - the keyboard begins to slide up then immediately slides down (~ < 1 sec) leaving the following interface:
I can't for the life of me figure out what would cause the keyboard to hide when not running from XCode, but work perfectly well when it is.
Is there any way to 'force' the keyboard to display, or possibly put the whole modalviewcontroller as first responder in some form or fashion?
Any suggestions are appreciated!
Edit:
The keyboard WILL appear again if you click in the contact area
You must add MessageUI.framework to your Xcode project and include a
#import <MessageUI/MessageUI.h> in your header file.
try this code may be its helpful to you..
[self presentModalViewController:picker animated:YES];
//[self becomeFirstResponder];//try picker also instead of self
Also Refer this bellow tutorial and also check demo..
new-tutorial-developing-and-architecting-a-phonegap-application
SMSComposer
i hope this help you...
I encountered these symptoms with a Sencha Touch 2.2 and Cordova 2.6.0 setup (specifically, iOS 6+ devices).
The issue was with the web framework stealing focus away from the native SMS Composer modal, typically occurring after the first SMS Composer modal had been successfully displayed and closed.
A event.preventDefault() and event.stopPropagation() call once the event had been fired (or event.stopEvent() in Sencha land) resolved this.
Hope this helps,
-James
First: The most likely culprit, without seeing your code, is that your parent (presenting) view controller may have an action in its viewWillDisappear or viewDidDisappear that is affecting who has the "first" responder. These methods get called when presenting a view controller modally. It may be behaving differently on the simulator than the device due to timing - often really close timing conditions are different on the ARM device and the i386 processor.
Second: Does anywhere in your app register for the UIKeyboardWillShowNotification or the UIKeyboardDidShowNotification? If so, put breakpoints in the methods that are called as a result - it's possible some other controller in your view hierarchy is interfering with this one.
To answer your question...
Is there any way to 'force' the keyboard to display, or possibly put the whole modalviewcontroller as first responder in some form or fashion?
No to both. The only way to make the keyboard display is to call the becomeFirstResponder method of the input view. Since Apple doesn't expose the text view, you cannot send it messages. Setting the modalViewController as first responder would be setting the wrong object.
I found the same type of issue But Not Sure it will Solve your problem or not Just Have a Look on the Following Links :
1. http://community.phonegap.com/nitobi/topics/keyboard_is_not_triggerd_in_my_ios_build
2. https://github.com/phonegap/build/issues/31
If its not Solving your issue then you can Download the Sample code Here.
Link: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/SMSComposer
UPDATE: cut/copy/paste disabled in my app.
I am confused with my iOS app while developing for iPhone devices. Execution flow enters a point like the code below
[self navigationController] pushViewController:chooseDeviceView animated:YES];
[chooseDeviceView release];
[numberTextField setText:#""];
The view changes and things "work properly". The problem is that after this the cut/copy/paste functionality is missing in my app.
Don't really know how to start debugging the issue. Does it ring a bell to anybody?
That was a very complicated issue for a beginner. Finally the issue was a little bit related with status message corrupts main window in my iPhone app
Add in your new viewController this:
- (BOOL)canBecomeFirstResponder {
return YES;
}
It should solve your issue.
My app which use to work perfectly being compiled in xCode 4.0.2 no longer works correcly compiled in xCode 4.2 with the new SDK.
My modal views are working very different, some states not being detected, or other dismissals not working. For example this use to work to dismiss 2 stacked modal views:
if(self.parentViewController.parentViewController)
[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];
else
[self dismissModalViewControllerAnimated:YES];
Now this just dismisses the first view...
I've been looking for documentation on these changes but have found none. Primary app delegate seems to be working differently too.
Help greatly appreciated.
There is a new property in iOS 5 named presentingViewController. The meaning of parentViewController got changed a bit with the new container view controller API, so it may not always be set when you think it is. That's what presentingViewController is now for.
if ([self respondsToSelector:#selector(presentingViewController)])
[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]; // for IOS 5+
} else {
[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES]; // for pre IOS 5
}
hey i am beginner in iphone application development.
i developed simple application in iphone but i also required it in ipad so for that i start coding for ipad but i didn`t get navigation properly in ipad code through
[self presentModalViewController:navController animated:YES];
[self.navigationController presentModalViewController:navController animated:YES];
for that i use addsubView Method but it didnt get its navigation controller from viewdidload method.
and please tell me how much this type of diffrences b\w iphone and ipad applications.....
if thier is any tutorial on ipad appication than tell me..........
Main difference between iPhone and iPad app is UI design, code behind the logic is same if you are using same components, there are some of the UI elements which are only iPad only like splitview, popup view as you start using these your code behind also changes.
you will get many samples on apple developers.