Placeholder for textfield problem in ios 4.2 - iphone

I have a UITextField in a table custom cell.I had set TextField text alignment to UITextAlignmentCenter.I have also added placehoder text to this textField & made this textField firstResponder .Now , what happens is in ios 3.0 & 4.0 , it works perfectlty (cursor blinks in the center & text entered is also in the center)
But in ios 4.2.1, cursor blinks in the left, while the text entered is always center aligned.If I remove placeholder text, even in ios 4.2.1 everything works well.

My opinion regarding the issue:
If you notice the cursor position in prior versions(iOS 4.0 and 4.1),
you can notice that the cursor is not placed exactly at the center of the
placeholder text. But in 4.2 the cursor is placed neatly at the left side of
the placeholder.
Have a look at the following screen shots.
Cursor position in prior versions (iOS 4.0 and 4.1):
Cursor position in iOS 4.2:
If we notice the cursor position is improved in 4.2 and it looks better than the older versions.
I guess Apple has made this intentionally to make it better.

Related

How to change the background color of keypad in iOS 7

I am using Xcode 5 for developing applications. I want to change the color of keyboard in iOS 7. I want a color like black or blue.
How can I change the color of keyboard in iOS 7?
You can only set the keyboard appearance to any of three listed below using the UIKeyboardAppearance.
UIKeyboardAppearanceDefault // Corresponds to the UIKeyboardAppearanceLight
UIKeyboardAppearanceDark // Available in iOS 7.0 and later.
UIKeyboardAppearanceLight // Available in iOS 7.0 and later.
There is one more constant named UIKeyboardAppearanceAlert but, that is now deprecated. You should use UIKeyboardAppearanceDark instead.
You can't use any custom or undefined color.
So, Use ...
myTextfield.keyboardAppearance = UIKeyboardAppearanceDark;
In iOS 7, since the keyboard is translucent, I was able to accomplish this effect by adding a colored subview behind the keyboard that shows and hides with keyboard notifications.
I created a GitHub project to demonstrate this technique. Keep in mind it only works in portrait orientation right now and obviously only in iOS 7.
https://github.com/meekapps/TintedKeyboard
You can change the color with the keyboardAppearance method.
_textField.keyboardAppearance = UIKeyboardAppearanceDark;
Have a look at the Apple API docs
Per your comment of wanting a custom color:
You could do this... Just use the normal keyboard, then observe UIKeyboardWillShowNotification and UIKeyboardWillHideNotification so that you can show a color UIView behind the keyboard.
It would be hacky, but it would work because the default keyboard is transparent to a degree on iOS 7.
Good luck.

No button events in iphone 5 simulator

When I test my app running in the iPhone 6 simulator everything works as expected. If I however test it in the iPhone 5 or iPhone 5.1 simulators, I can't seem to get button events fired. Im using Xcode 4.5.2, not using storyboards and I have made tests with simple buttons with actions like:
- (IBAction)test:(id)sender {
NSLog(#"YEES");
}
And the actions is connected using drag and drop in the interface builder. I just can't seem to get it fired.. Do you have any idea about what could be the problem?
Update Jan 18:
If I do a "normal" click on a button in the iPhone 5/5.1 simulator nothing happens. If I do a bit "slow" click on a button the button will be "pressed"/selected. If I do a "really slow" click, like holding the button down for 3 seconds I get the button click event! How is this possible??
I found a solution for my case - i added UITapGestureRecognizer to the container UIView, and it intercepts events before UIButtons, and need some time to fail before buttons can handle tap... But it strange that in iOS 6 all works fine
To avoid this we can simply call:
[tapRecognizer setCancelsTouchesInView:NO];
I really suspect this could be the issue of view overlapping.
Please color your views that you are using on the view controllers and check whether any of your view is overlapping your button or not
I had a similar issue with an iPhone 5s simulator. Through trial and error I realized that the button's height in the simulator was 0 or otherwise a small number... The first clue to that was that when I changed its background color - the background did not show in the simulator (on larger simulators, like 6 or 6 plus, it showed as a thin line instead of full height). Then when I added a height constraint, it started accepting click events. That helped me identify the issue, but it was not the solution I was looking for. Initially I laid the button out without size constraints, so it's actual size should have been determined by it's intrinsic size. So instead of the height constraint, I changed the vertical compression resistance of the button to "required". That fixed the issue.

X button with circle in iPhone Controls

You know that grey circle with white "X" in it in textboxes for iPhone controls that is used to delete the current line of text, is that available as an icon somewhere? I'd like to put that icon along with the words "Clear" into a UIButton but not sure if that is availalbe. Thanks.
Apple's website uses a reset icon in its search field that you could download. Not sure how well it will work with the iPhone 4 display PPI though. (It doesn't seem to appear when I visit the site with an iPhone.)
This is not part of the public API, you'd have to use your own custom image. Which could simply mean using an editor to slice it out of a screen shot.

Changing the cursor in iPhone simulator?

How can I change the cursor pointer to hand in the iPhone (simulator)?
I tried it with the css cursor: pointer; but nothing
happens in the iPhone simulator. It still remains the default pointer not changing to the
hand symbol.
Why? Can it be fixed?
There is no such thing as a pointer on iOS devices. (Unless you want to use CSS to put gloves on my hands...)
In regards to the simulator, I suspect that CSS support for the cursor attributes would limited if it's there at all, since the simulator is supposed to behave like the device and there is no cursor on iOS.
The cursor which you see is the cursor of your Mac. Pretend that it is on top of the "glass" of the simulator. Safari mobile doesn't know that it is there.
I was also looking for a way of changing the cursor but I couldn't find anything. At the end I used Mousecape and added a custom cursor that resembles a finger shadow. I compiled the steps I followed here -> https://medium.com/#castillejoale/changing-mouse-cursor-in-xcode-simulator-72f768f5b434
Hope this helps

iPhone SDK > 4.1, UISearchBar does not respond to keyboard input if subview of an UIAlertView

Testing in the simulator for iPhone SDK > 4.1, UISearchBar does not respond to keyboard input if it is a subview of an UIAlertView.
Tests on the iPad simulator 3.2 and on a 3.1 iPod Touch device both succeed, while on the 4.1 and 4.2 simulators, I can only use the keyboard to delete existing text (that I set from code), not to input text: the typing animation appears, yet no text is inputted in the UISearchBar.
There is no such behavior when using an UITextField, so it further strikes me as a very curious bug.
Can anyone else test this on a real > 4.1 device and confirm/infirm this and perhaps come up with a solution/workaround?
It seems that it's a simulator problem, the actual devices run the code in this scenario with no issues whatsoever.