How to know which key is pressed on UIKeyboard in ios? [closed] - ipad

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am implementing a iPad application. In my application I need to know which key is pressed in the keyborad. Can you guys please help me is there any way to find it?
Thank you,
Sekhar.

This is a vague question, but if you simply want to know what key has been tapped you need to implement a delegate for input control that called the keyboard. For example if you are using a UITextView, then implement the UITextViewDelegate, wire up the control's delegate property to you class, and then implement the textView:shouldChangeTextInRange:replacementText:. When UITextView recognizes a change then it will call this method. You can then watch for the characters in the "replacementText" argument.
With UITextField use the UITextFieldDelegate and implement the textField:shouldChangeCharactersInRange:replacementString: method.
You can do other things with UITextField like change the Return button to a Done button in Interface Builder. The implement the textFieldShouldReturn: method. If it's called then run the resignFirstResponder on the object passed to the method.
Hope this helps.

Related

Changing UIImage using an IBAction [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Good morning,
I am trying to create a button, that, when pressed, will change the background to a different image.
For example; we have;
background1.png
background2.png
background3.png
background4.png
background5.png
background6.png
background7.png
background8.png
background9.png
I want the app to start, and use background1.png as the default.
However, I would like to set a UIButton, to change the background when pressed, that will just cycle through the backgrounds from 2-9.
Is that possible to do at all? At present the Background image is set in the IB using 'background1.png' so I am guessing I would need to remove that, and set it to appear in the viewdidLoad?
Sure, set the image view containing the background image to an IBOutlet.
Then, in the IBAction pointed to by your UIButton, each time that action is called you can cycle through the various image files and set the image contained in the UIImageView.
e.g.:
- (IBAction) changeBackgroundImageAction: (id) sender
{
// someIndex can be an ivar or something else...
NSString * imageFileName = [NSString stringWithFormat: #"background%d.png", someIndex];
backgroundImageView.image = [UIImage imageNamed: imageFileName];
}

How do I find what to refer to a UIButton as? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want a particular UIButton to change colour once a UISwitch move from OFF to ON. What do I enter
- (IBAction) Court1ON {
//here
}
to refer to a specific UIButton in my storyboard?
You have several possibilities to do that:
assign a tag to your button in storyboard; then access the button through:
[self.view.viewByTag:buttonTag];
create an IBOutlet #property of type UIButton and bind that to your button.

How to speed up scrolling in UIScrollView? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to make paging/scrolling in UIScrollView to be faster, so when the user lefts his finger the next page will come faster than normal regardless the speed of the acceleration.
Tweak the decelerationRate of your UIScrollView.
More reading: UIScrollView Class Reference
If I understand your question correctly, you've setup the ScrollView to snap to pages (pagingEnabled = YES). When the the user lifts their finger you want it to snap to the closest page quicker than what it currently does?
If that's what you're trying to accomplish, this is what I recommend:
DISABLE pagingEnabled (pagingEnabled = NO). We're going to do it ourselves.
Setup some object (probably the ViewController) as a delegate of the scroll view.
In the Scrollview delegate, override the method scrollViewDidEndDragging:willDecelerate:. You will also want to override the method scrollViewWillEndDragging:withVelocity:targetContentOffset: so that you can get the velocity of the drag.
In the scrollViewDidEndDragging:willDecelerate:, you can calculate the direction of the drag (using the velocity you got from the other method) and the offset to the nearest page. From there, it's as simple as setting the contentOffset of the scrollview using a UIView animation block with the desired duration. For example:
[UIView animateWithDuration:.25f animations:^{
scrollview.contentOffset = calculatedCGPoint;
}];
That should give you the desired effect.

How to hide UITextField, UILabel, UIButton on ViewDidLoad method? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am trying to hide my texts labels and buttons
Use the hidden property of UIView (UITextField, UILabel and UIButton are all subclasses of UIView).
myControl.hidden = YES;
go to the .h File for the view controller and make an IBOutlet with the data type appropriate for your control UITextView, UILabel, etc...
go to the interface builder and bind the IBOutlet you declared to the item you want.
Use myControl.hidden = YES;
Please do not hesitate to ask for clarifications for any of these steps.

How to pop up the EditText box when button is tapped,objective c,ios [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How to pop up the Edit Text box when the button is tapped using objective c.Am trying to do but i want some help.Can some body provide some samples for me.I made googling but am not able to find the solution.Please some body help me?
Ok, this is rather easy if I understood correctly what you need.
First, you need to make a new UIViewController, called let's say TextViewController
Inside TextViewController you place your UITextView, making it as big as you need, changing the font or whatever you might need/want.
After this all you need to do is to present TextViewController inside an UIPopoverController ( http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPopoverController_class/Reference/Reference.html )
The code should look something like this
TextViewController* textViewController = [[TextViewController alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:textViewController];
aPopover.popoverContentSize = CGSizeMake(320.0,110.0); //sets the size of the popover
[aPopover presentPopoverFromRect:yourButton.frame inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
where textViewController is the view controller with the UITextView and yourButton is the rounded button you tap on.
This tutorial should also be useful: http://www.raywenderlich.com/1056/ipad-for-iphone-developers-101-uipopovercontroller-tutorial

Resources