iPhone custom keyboard - iphone

I'm creating a custom keyboard with say 10 UIButtons laid out in a horizontal row. The buttons span the width of the screen, are the same size and must sit flush against each other.
I would also like to allow the user to choose a button by sliding a finger along the row of buttons. A preview of the chosen button is displayed elsewhere on the screen. The preview updates as the user moves their finger along the row. When the user is happy with their choice they release their finger, confirming the selection.
The obvious thing to try is UICountrolEventDragExit or UIControlEventDragOutside to remove the action of the previous button and UIControlEventTouchUpInside to activate the current button and kill previous touch events. However UICountrolEventDragExit and UIControlEventDragOutside are only activated when the user has dragged sufficiently far from the given button. Since my buttons must sit flush against each other this is too far and not good enough for me.
Suggestions?

Disable user interaction on the views used to display the buttons, and track all touches through the containing view. This is similar to how Apple's keyboard code works.
(alternatively, you could draw all of the buttons directly in the drawRect: of a single keyboard view, but that won't look proper during orientation changes)

If you want a 10 button 'keypad' I would look at using a UISegmentedControl. You can create one with 10 segments each with its own key and receive the key selected programatically like:
segmentSelected = mySegmentControll.selectedSegmentIndex;

Calling
-(void)touchesBegan:(NSSet )touches withEvent:(UIEvent)event;
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
judiciously with a view showing 10 UIImages (not UIButtons) also works fine.

Related

touch events on UITextField rightView

I have several text fields which compromise a registration form . When the user hit submit and made invalid inputs the wrong fields are marked with an icon as rightView.
The rightView i use is a custom UIImageView subclass which has it's:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
overwritten to display a alert to tell the user what exactly is wrong with this field.
The problem is that the touchesBegan method is never called. Why is the view not receiving touch events when I touch it?
you need to enable user interaction of images to TRUE
[imageView setUserInteractionEnabled:YES];
You should check whether your view is on the upper level of views (that it's not overlayed by another transparrent view)
And also check for view's user interaction set to ENABLED
Also check that you tap directly on the view, this method is called only when you tap within your view's bounds
I also recommend you to read a bit about UITapGestureRecognizer class may be this would be more convenient way to use...

hide keyboard by dragging finger like sms app in iOS 5

I have a chat feature in my app and I am trying to hide the keyboard by dragging the finger downward just like how you can hide the keyboard in the sms app in IOS 5.
I have subclassed UITableView, however as soon as scrolling starts I no longer get calls to
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
I am wondering how I can get scrolling and find out where the finger is during scrolling so that if it starts to get close to the keyboard I can start to hide it.
I think this is a feature lots of people will want, any ideas on how to make it?
DAKeyboardControl it an MIT Licensed code source for what you are looking for.
Further googling revealed that this question is a duplicate of:
How to move iPhone keyboard down like in Messages.app?
I had enabled this feature in my app, with the help of Daniel's DAKeyboardControl library. You can implement the iMessage style keyboard hiding acidity with just one line of statement:
[self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {
// Move interface objects accordingly
// Animation block is handled for you
}];
UITableView inherits from UIScrollView, so you can detect the scroll position with UIScrollViewDelegate methods like - (void)scrollViewDidScroll:(UIScrollView *)scrollView
Luckly in iOS 7 Apple added the handy property keyboardDismissMode on UIScrollView. Now your app can behave like Messages just by changing a single property on your Storyboard, or by adding a single line of code.
This property uses the new ScrollViewKeyboardDismissMode enum. The possible values for the enum are as follows.
UIScrollViewKeyboardDismissModeNone
UIScrollViewKeyboardDismissModeOnDrag
UIScrollViewKeyboardDismissModeInteractive
Here is the storyboard property do dismiss the keyboard on scroll

how to flick and scroll horizontally

I am trying to do something similar to http://www.winktoolkit.org/previews/63/
As you can see from the youtube video, It has three section I need to do two only.
So the idea is there will be bunch of images divided into two sections and both the sections can be scrolled horizontally by just flicking just like iphone photo app, you see an image and flick it you see another image, you can flick backward and forward. To be more specific, I have put an image of the wireframe that I am working on
https://picasaweb.google.com/lh/photo/PZ-3H3VEujd7b2w9V3UJlJSL2rubFpkbdgdHPXy8M2Q?feat=directlink
EDIT: I should also be able to find out, which image the user has taped on, based on that I have to take some action, for example a detail page.
Thanks for your help.
Thanks,
Yogesh
U can use page control.They are also using page control in the video.
The video looks like its a webpage. You might want to consider have a tableview with scrollviews in each row
To detemine which image has been pressed you can add each image as a button not just a standard image and tag each button
Set the delegate of the button and handle the button press, pull out the tag and deal with it
If you want to code it in Objective-C, you need a UIScrollView and set it's property pagingEnabled to YES and the property contentSize to widthOfOnePage*numberOfPages.
To get the "bullets" you need a UIPageControl. Keep in mind that the UIPageControl does not get updated automatically but you can use the UIScrollView delegate method - (void)scrollViewDidScroll:(UIScrollView *)scrollView to update the active bullet in the UIPageControl.
For getting the image the user tapped on, use the - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event method.

Display tooltip on UITableView in iPhone

I was wondering if anyone has tried it. I need to show a tooltip within a table view when the user selects a word in the row's text.
Can you please help me or suggest any way for this?
Thanks in advance!!!!!!
In each cell add a UIView (be it a UITextView, UIImageView or whatever, in fact you can add plenty of additional subviews to it). Say you call it "tooltipView".
Now when user selects text, all you have to do is position (move around) that view near the selection (or where the user touched the row) and set the relative information. To track the selection, you can simply override the - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event method of your cell class and keep checking the point variable and corresponding event.

UIButtons creating a native-like keyboard behavior

Greets. A somehow detailed explanation on my problem, and what I have already done, and what I cannot do.
I want to create a behavior resembling the one in the iPhone's keyboard. Basically, I want a view to appear when the user taps a button and WHILE the user taps that button.
This, I accomplished.
When the user lets go of the button WHILE his finger is on that button's area, I want to trigger an action "doing stuff".
This, I was also able to do.
Since all the buttons are near (like in the keyboard) and I don't want the user to select other button than the one he pressed, I reduced the hit area for the button using the -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent )event function.
When the user presses the button, not lifting its finger, and dragging outside the button area, I want another action to trigger. This is the first problem... This function only triggers when the user's finger is far from the buttons' area, and this time the pointInside function is not being my friend. How can I detect the user finger "left" the button area the moment it exits its bounds?
This, in case you didn't realize... was problem 1.
The second problem is related with the drag enter. Again, I need to limit the area like in the drag exit. But I suppose that when I solve one of these, the other is the same. The problem is that in order to have a behavior like in the keyboard, I may need to detect the user started the touch in another button, never lifted his finger, and changed to another button. I can detect drag enter and drag exit IN THIS ORDER while on the same button. I cannot detect drag enter when the user first touched anywhere else other than the button where I want to detect the drag enter event. Basically what I need is to detect touch on any button (and not anywhere else in the view), and while the user is changing buttons without lifting the finger, I want to detect the new button being touched.
This gigantic paragraph was problem #2.
Any help, as you might guess, is highly appreciated.
Best Regards.
Thanks a lot!
Solved.
I used a custom UIButton class. Then, in
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
I test if the touch occurred in that custom UIButton. And if it did, I act accordingly.