iPad iOS 9 having issue in display keyboard when select textfield - objective-c

My app is iPhone based app , while running my application in iPad device
I select the UITextField, It takes 10 to 20 secs to display the keyboard for the first time in the iPad device alone,but later it working fine in displaying keyboard, Its a strange thing,
Please help me to get rid of this problem

This worked for me.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Preloads keyboard so there's no lag on initial keyboard appearance.
UITextField *lagFreeField = [[UITextField alloc] init];
[self.window addSubview:lagFreeField];
[lagFreeField becomeFirstResponder];
[lagFreeField resignFirstResponder];
[lagFreeField removeFromSuperview];
}
Taken from this stack overflow answer: Super slow lag/delay on initial keyboard animation of UITextField

Related

xcode7 without storyboard, display not right [duplicate]

This question already has answers here:
iOS 9 Xcode 7 - Application appears with black bars on top and bottom
(17 answers)
Closed 6 years ago.
I am working with xCode7 and I am trying to not use storyboards. I have deleted both the launch screen and the main storyboard properties from info.plist and I have created a xib file that is properly linked to the view controllers. In my app delegate I have written the following code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
UIWindow *window = [[UIWindow alloc] initWithFrame:screenBounds];
ViewController *vc = [[ViewController alloc] init];
[window setRootViewController:vc];
[window makeKeyAndVisible];
[self setWindow:window];
return YES;
}
My xib file looks like this in the editor:
Those buttons are there to show the top and bottom.
In the simulator it looks like this:
Can anyone throw some light into the matter? Thanks, P.
This looks like you should take a look into your Top Bar and Bottom Bar. Make sure is none. I hope this can help you.
[viewController.navigationController setNavigationBarHidden:YES animated:YES];
and
[viewController.navigationController setToolbarHidden:YES animated:YES];
I didn't test it on xcode, maybe there is some errors in my code.
I hope this can help you.

Unable to detect iPhone Retina 4-inch screen size in simulator

I want to make my iOS application support iPhone 5. So I created a separate xib set for iPhone 5 size. Then I load each xib by checking the screen height.
This is the splash screen loading code inside the AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1;
if ([UIScreen mainScreen].bounds.size.height==480) {
viewController1 = [[SplashScreen alloc] initWithNibName:#"SplashScreen" bundle:nil];
}
if ([UIScreen mainScreen].bounds.size.height==568) {
viewController1 = [[SplashScreen alloc] initWithNibName:#"SplashScreen5" bundle:nil];
}
self.window.rootViewController = viewController1;
[self.window makeKeyAndVisible];
return YES;
}
But when I change the simulator into Retina 4-inch, my code doesn't get the emulator size. It always executes the 480 if condition.
But other apps I created like this are working properly.
What is the reason for this?
I'm having the exact same problem right now (at the worst moment, of course....).
It did work properly for several weeks, and for a unknown reason, the simulator suddenly considers the 4in simulated device as a 3.5in screen.
cleaning, reset, reboot : same situation...
EDIT : ok, problem solved. T'was because of a missing Default image in the -568#2x format. I knew that was a condition to make the system work, but xcode had apparently decided to get rid off the one I chose. oh well...

UISwipeGestureRecognizer works for touches 1 and 2 but not 3

The following does not work — handleSwipeUpTriple is never called:
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UISwipeGestureRecognizer *swipeUpTripleRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(handleSwipeUpTriple:)];
swipeUpTripleRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
swipeUpTripleRecognizer.numberOfTouchesRequired = 3; // triple finger
// window is in nib
[self.window addGestureRecognizer:swipeUpTripleRecognizer];
[swipeUpTripleRecognizer release];
}
- (void) handleSwipeUpTriple:(UISwipeGestureRecognizer *)sender {
printf("\nhandleSwipUpTrpl called."); // never happens
if (sender.state == UIGestureRecognizerStateEnded)
printf("\n SwipeUpTriple recognized.");
}
}
The weird thing is that if I change the numberOfTouchesRequired to 1 or even 2, it works. Only 3 (or 4) fingers seem to be out of bounds. Since I see a number of posts regarding 3-finger gestures, I don’t see why this should be.
self.window.multipleTouchEnabled is YES.
For testing purposes, I have removed all subviews. There’s nothing but self.window on the screen.
I’m still using iOS 4.3, but since UISwipeGestureRecognizer was available by iOS 3.2, I don’t see why that should be a problem.
I know that the non-iPad devices sometimes are running system gesture recognizers for 3 fingers (usually zoom). Depending on your settings the system may have reserved this number of fingers for itself.
As we found, you can fix this by going to General > Accessibility and disabling the three-finger gestures.

Launch screen delay works in iOS Simulator but not Device

I've set my launch screen to only display for 1 second using the code below sleep(1); in the app delegate, but when testing directly on a device, I have to wait for the full 5 seconds.
Every time I run a test using an iPhone, or an iPad, I have to wait the full 5 second default before the app will load, however, it works great in the simulator.
If I unplug the iPhone cable, the sleep() function works on the devices. Is there a setting in xCode for this?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(1);
...
}
In order to delay the launch screen this is not the recommended method. This just delays the whole process.
I recommend you add a new viewController to the very beginning of your project which will show immediately after the launch screen with a UIImageView containing the exact same image as the launch Image.
Then add a delay from there before switching to the original first screen. This way you can even add a new different kind of transition to the launch image.
#import "OrginalController.h"
- (void) gotoOrginalFirstScreen
{
// This function will take you to your oringinal first screen
// from the temporary screen with the launch image
OrginalController *controller = [[OrginalController alloc] initWithNibName:#"OrginalController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:controller animated:YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// add this line to call the transition and the delay
[self performSelector:#"gotoOrginalFirstScreen" withObject:nil afterDelay:1.0];
}
you can display the launch screen without putting it to sleep itself. You don't need a separate view controller also. This method will work anywhere and wont trouble you also.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"splashscreen.png"]];
imageView.frame = CGRectMake(0, 0, 324, 480);
[window addSubview:imageView];
[self.window makeKeyAndVisible];
[self performSelector:#selector(firstscreen) withObject:nil afterDelay:1.0];
return YES;
}
-(void)firstscreen
{
// Load some View
}
this you can put it in you application delegate this will show your splash image for 1 sec after which the next screen will be loaded.

Adding splashscreen to iphone app in AppDelegate

I'm running xcode-4.2 and the project is based for ios5 using storyboards.
I've created a single view application , using the template provided by Apple.
In the storyboard I the removed the viewcontroller created for me and added a UITabBarController.
Next I added a new class MyTabBarController which is a subclass of UITabBarController.
Now I want to show a splashscreen before the TabBar appears. So I can do some loading and calculation in the background.
I thought AppDelegate.m would be a good place for this. Since that's the place where my rootview get's loaded not ? Or should a show the splashscreen from the rootviewcontroller which is MyTabBarController in my case ?
So I created a xib file. I'm surprised you can add .xib files to ios5 storyboard projects. The xib file is called SplashView.xib it has a single view with an image on it.
Code in AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_splashScreen = [[UIViewController alloc] initWithNibName:#"SplashView" bundle:nil];
//_splashScreen is defined as:#property (strong, nonatomic) UIViewController *splashScreen;
[_window.rootViewController presentModalViewController:_splashScreen animated:NO];
[self performSelector:#selector(hideSplash) withObject:nil afterDelay:2];
return YES;
}
The problem is nothing happens. Even if I change the value from 2 to 200. The application starts up as if there is no splashscreen.
As you might have noticed I'm still struggling with the design of objective-c and iphone application. I hope a decent answer to my question will bring some clarity to the subject.
Thanks in advance!
Splash screens are built into iOS apps. All you need to do is create a file called Default.png and Default#2x.png (for retina displays) and it will work as a splash screen for when the app launches.
You can also set what these images will be in your apps info.plist.
I've dealt with a few clients who wanted to use an animated splash.
Though I'm totally against this, following Apple's HIG,
those clients just don't understand...
Anyway, since - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; has to return boolean,
it's very important not to halt it for anything.
Also, since launch time is measured by iOS, if it's taking too long, the app will be terminated by iOS!
For this reason, I often use - (void)applicationDidBecomeActive:(UIApplication *)application;
with some kind of flag to indicate if it happened at launch or at returning from background mode.
Or, you should use a NSTimer or - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;
so, didFinishLaunchingWithOptions can return without being blocked for processing your animated splash.
This delayed performSelector should be implemented not only for hiding action (like the way you intended it), but also for starting the animation.
If you are using storyboard, you can just add the splash UIImageView to your window.rootViewController.view like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImage *splashImage = [UIImage autoAdjustImageNamed:#"Default.png"];
UIImageView *splashImageView = [[UIImageView alloc] initWithImage:splashImage];
[self.window.rootViewController.view addSubview:splashImageView];
[self.window.rootViewController.view bringSubviewToFront:splashImageView];
[UIView animateWithDuration:1.5f
delay:2.0f
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
splashImageView.alpha = .0f;
CGFloat x = -60.0f;
CGFloat y = -120.0f;
splashImageView.frame = CGRectMake(x,
y,
splashImageView.frame.size.width-2*x,
splashImageView.frame.size.height-2*y);
} completion:^(BOOL finished){
if (finished) {
[splashImageView removeFromSuperview];
}
}];
return YES;
}
I think the reason why directly just add the UIImageView to window is because iOS will bring the rootViewController.view to front when the default splash will hide. And this will overlap the animation. This means the animation does happen but it's behind the rootViewController.
I just add an identical image to the launch image to my first view controller and then fade it (or whatever animation you require) - this avoids pausing the app load in the AppDelegate.
You need to ensure that the image has the same size and origin as your launch image e.g. to set the image to display on my first view controller which is a tableViewController:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.tableView.bounds];
imageView.image = [UIImage imageNamed:#"[imagename]"];
[self.tableView addSubview:imageView];
[self.tableView bringSubviewToFront:imageView];
// Fade the image
[self fadeView:imageView];
-(void)fadeView:(UIView*)viewToFade
{
[UIView animateWithDuration:FADE_DURATION
animations:^ {
viewToFade.alpha = 0.0;
}
];
}