iOS 5 SDK treating UIViews differently - iphone

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
}

Related

Using EGOPhotoViewController with iPhone 5

Using this on iPhone 5:
EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithImageURLs:imageURLs];
[self.navigationController pushViewController:photoController animated:YES];
When I get back to the caller I can see the bottom bar... How should I solve this?
That doesn't happen on 3.5 inch screen.
UPDATE:
Same problem happens on EGOPhotoViewer_Demo
This is how the screen looks on the first usage:
When getting into "Photos" and go back to that main screen it change to:
You can see something hides the bottom of the screen. On my app I have buttons there so it's problematic.
Hope this update makes my problem more clear.
I’m not sure but this might be a duplicate of iPhone 5 app displaying correctly but not sensing touches in “extra” space
Also, do you have the same problem on iOS 6? From the screenshots, it seems you are using iOS 7, which could be the source of your problem.
When compiling with Xcode 5 the problem is solved (test device was iOS 7).
I had the same issue.
The problem is the following statement in viewWillAppear:
[self.navigationController setToolbarHidden:NO animated:YES];
Move this statement and the accompanying "if" test to viewDidAppear and the problem goes away.
To be honest I am not sure why this ever worked - but it makes sense that showing the toolbar when our photo view is not yet up would show the toolbar in the parent view, not the photo view. Moving it to viewDidAppear does the right thing.

iOS Version Checking gives warning

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!.

Keyboard shows then immediately hides itself when showing MFMessageComposeViewController

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

cut/copy/paste functionality stopped working in my iOS application

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.

ViewDidAppear crashes on iOS 5.0 simulator

The following code works fine from iOS 3.0 to iOS 4.3 simulator but crashes on iOS5
-(void)viewWillAppear:(BOOL)animated {
[self.tableView reloadData];
[super viewWillAppear:animated];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.navigationController viewDidAppear:animate];
}
I got exc_bad_access in [self.navigationController viewDidAppear:animate] and it makes the app crashes.
It works fine without any problem in the previous verison.
This app is developed in XCode4 with deployment target 3.0. My user just found the app crashes when he upgraded his iPhone with iOS5.
I am being able to reproduce theproblem but not sure how to fix it.
Can anybody shed some light?
[self.navigationController viewDidAppear:animate]; is the problem here. In iOS 5 it's going to recursively call this view controller's viewDidAppear method over and over until it just crashes. Why exactly do you need to call viewDidAppear manually on your navigation controller? If it's actually necessary to get your code working, you might want to backtrack a bit as something else must be wrong if you're needing to do this.
One other thing that's just good housekeeping: in your viewWillAppear, [super viewWillAppear:animated]; should come first it that method.