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