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

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.

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];
}

Set background color for UIView [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 have a problem when setting the background color for a UIView. What I am doing is:
- (void) viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];
}
but I am getting a black background color as shown below:
If I change the background to any another color it works. Any ideas about this ?
Your view is working as intended. You are setting it to use a clear background color, which means exactly as it is named, clear, and you will see color and possibly other UI elements underneath your view. Think of it as placing clear plastic wrap (the view) on top of colored construction paper (the super view). If you wish to find where the black color is coming from, I would start with your root controller's view.

How to know which key is pressed on UIKeyboard in 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.
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.

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