I've read here in many questions how to limit the length of my uitextfield programmatically by implementing shouldChangeCharactersInRange method but isn't there a way to do it in storyboard? it seems, to me,like a bad performance practice to check it with every keyboard click
In every other programing language i know that has an IDE + ui editor the control has a property to set max length same as it has for setting the text, font, border style etc.
There's no way of setting that from the storyboard, as is a method that is called by the delegate, so you need to do it programatically.
You can't set a maximum character limit by setting something in the storyboard. You need to do it programmatically. And as long as you're just doing character limit checking, there's no noticeable performance impact to this. In fact if you think about it, regardless of whether you implement the check or it was somehow a storyboard option, it would still have to execute some code each time to see if it could add another character. Also this is so insignificant compared to the work involved in redrawing the screen that you would not notice any difference at all.
It's important to note in implementing a character limit check that you also have to handle when the user pastes text in, because this adds many characters at once. So you have to decide on how to handle that, whether you take just the characters up until your limit, or if you don't accept any of them because it exceeds your limit.
You also have to handle the case that the user is adding characters from the beginning or somewhere in the middle. Do you start deleting characters off the end to stay within your limit or not accept new characters anywhere in the string? These are decisions you have to make and account for in your code.
However, as I said before, all of this is so minor a burden on the processor that you won't notice any difference.
Related
If I turn the autocorrection ON, the words get autocompleted, as if I write "wor", I get "word" before I finish writing. I don't want this to happen because I might be writing "world" or any word different than the autocompleted one.
I set Correction off in the Interface Builder and this problem is solved.
The problem now is that I still need the suggestions that appear in a little popover below the incomplete words.
This two features might be different but I don't know how to activate the suggestions.
How can I solve this?
This can be solved with the use of tableview. Create a tableview with the width as of the width of the textfield and height as you like. Place it just below the textfield. Make it hidden initially. When the user starts typing, fetch the array of data that resembles to the typed text and if any exists then, unhide the table view. On the subsequent typing keep on reloading the tableview sections with animations. You should be accurate on hiding, unhiding and then reloading the data on the tableview. I have implemented such thing before. It is really easy and once you get started with it you find it easy.
In the UITextView TextViewDidChange I created a thread that changed the cursor position. This, off course happens after the text view changes. The change of the cursor position triggers the autocomplete without letting me even see that there had been a suggestion.
i want my app to be able to track a person when he moves 2 dimensionally upwards. I already have a vertical scroll view, and it works, but when i press a button i want it to track a little stick figure as he walks vertically, how can i control this? i thought of setting the scrollview.contentoffset to a certain position, but it just changes it one time when i want it to change it fluidly. i suppose i could make a timer that updates the contentOffSet every like .001 seconds or something, but i thought there maybe a better way.
Also, while i was searching the UIScrollView's methods, one of them was an isTracking method, which is a boolean, and I'm assuming it returns yes if the scrollview is tracking something, so given that i assume there is a feature in scrollview so that you can track things. Also, if to track things you have to use some other framework thing that would be helpful to know too
THANKYOU FOR ANY HELP!
The property tracking tells if the scroll view is currently tracking the user's movement. So that definitely won't help you out. (See David H's post for a better explanation for what the property indicates.)
However, you could use setContentOffset:animated: and set animated to YES. That results in a smooth transition to the new content offset.
Instead of calculating a reasonable content offset you might find it easier to specify an area that contains the stick figure. If so use scrollRectToVisible:animated:. Obviously animated should be set to YES.
1) don't use contentOffset = x;, use "- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated". Experiment how often you need to send this message, but I'm guessing you can do it no more than 10 times a second and get nice results.
2) isTracking means the user has their finger on the scrollView but has not started dragging it. By testing "isTracking" and "isDragging" you can determine if the user is fiddling with your scrollView or not.
Can I use UIKeyboardWillChangeFrameNotification to prevent the user to change the keyboard layout? I've some buttons on it and I don't want the splited keyboard, because it creates some ui problems.
Thank you in advance.
No, you have no control over the behavior of the system keyboard. Your only real option is to make your UI work properly with the split one. Keep in mind, though, that since the split keyboard can be moved, it doesn’t matter if it’s covering parts of your interface—if the user splits their keyboard, moving it out of the way of what they’re trying to interact with then becomes their problem.
I was wondering which would be faster/more efficient when it comes to taking off annotations from the map: hiding or removing. I need to remove and add 100 or so pins every time the user zooms in or out.
I can either loop through and hide all annotations using setHidden:, or just remove them using removeAnnotations:. I'm not sure which would be a better method.
I believe the standard method is to remove them. Less memory overhead. Not that 100 takes up that much, but still better to remove and re-add when needed then to hide.
I am working on a basic ordering UIViewController using the AQGridView to display multiple columns of products so I can use as much space as possible. For the time being I implemented UITextFields to enter the quantities for each product.
I am trying to find an alternative to UIPicker, some sort of dropdown. The fact that both, the entering text directly to the UITextField and the UIPicker bring up either the keyboard in the case of the UITextField or simply occupies a big portion of the screen from the start for the UIPicker.
Does anyone know of any alternatives to use? Or if there is a way to have a tiny UIPicker just on the cell for each product?
I guess I can simply play around with the individual cell and add the UIPicker with given CGRect. The thing is that it will still occupy quite some space.
Pickers are always the same size as the keyboard. Don't try to force a picker into a smaller space -- they look terrible when they're compressed, and that's like adding a note to the app store reviewers that says "Please reject my application."