I used segmentControl in UIScrollview. But my question is that user press first segment control all three field is shown on view.(By default). When user press second segment control three field should hide and remove between this space. Is it possible? Because in my view total 10 field is their. I want to hide 3,7,9 field.
Here is my segment control code.
- (IBAction)segmentedControlChanged:(id)sender
{
UISegmentedControl *s = (UISegmentedControl *)sender;
if (s.selectedSegmentIndex == 0)
{
[txtEmail setHidden:NO];
[sendInvite setHidden:NO];
[switchSendInvite setHidden:NO];
[allowComments setHidden:NO];
[switchAllow setHidden:NO];
}
else
{
[txtEmail setHidden:YES];
[sendInvite setHidden:YES];
[switchSendInvite setHidden:YES];
[allowComments setHidden:YES];
[switchAllow setHidden:YES];
}
}
Not possible directly whatever you are thinking, if you want to do like this you must change the frames of all the textfiled and relative objects in that scrollview.
Related
I have some UITextviews in my controller and I check if they have content. If not, I set them hidden. The problem is that even though i hide it, it retains its height. What can I do for it?
if([self.history.text length]<1)
{
[historyLabel setHidden:TRUE];
[history setHidden:TRUE];
}
if([self.history.text length]<1)
{
[self.history setHidden:YES];
[historyLabel setHidden:YES];
}
Try this..
Hello Im having trouble with my image view. i have a login view controller and i have a UIButton when clicked an image view animates across the view controller which is this:
- (IBAction)alreadyUser:(id)sender {
[_usnernameField resignFirstResponder];
[_passwordField resignFirstResponder];
[UIView animateWithDuration:0.3 animations:^{_loginOverlayView.frame = self.view.frame;
}];
}
but i can’t figure out how to undo this action i tried [_loginOverlayView setHidden:YES];
but then it states hidden when i try to come back to it
Appear:
[_loginOverlayView setHidden:NO];
Disappear:
[_loginOverlayView setHidden:YES];
you can put before or after the animation to hide or show the loginOverlayView.
Hi all I am developing a app were in that if we press the UIButton it will show the hiding buttons and once we press the same Button hiding buttons will hide again!!!
I successfully made the hiding buttons to reveal by using the following code:`
mapping1.hidden=NO;
mapping2.hidden=NO;
mapping3.hidden=NO;
but now i want to hide this buttons again by using the same button, how can i do that and if there any other possible way?
To make them hidden again, use
mapping1.hidden = YES;
if (mapping1.hidden)
{
[mapping1 setHidden:NO];
[mapping2 setHidden:NO];
[mapping3 setHidden:NO];
}
else {
[mapping1 setHidden:YES];
[mapping2 setHidden:YES];
[mapping3 setHidden:YES];
}
I have been creating "if/then" apps for android and now my boss want me to do the same for his iPad. I just need to figure out how to code so that when the buttons are clicked, it hides the current view (text and button) and reveals the next set of text and buttons.
Make sure your two sets of text/buttons are in two UIViews (I will refer to these as 'viewOne' and 'viewTwo'), when you want to swap your views, use this code:
[viewOne setHidden:[viewTwo isHidden]];
[viewTwo setHidden:![viewTwo isHidden]];
It's not the most understandable way to do this, but it's one of the shortest.
For something easier to read:
if ([viewOne isHidden]) {
[viewOne setHidden:NO];
[viewTwo setHidden:YES];
} else {
[viewOne setHidden:NO];
[viewTwo setHidden:YES];
}
Either will work, it just depends on how you like to write your code.
I have two buttons on my first view,so when I click on one of the button the view changes,so I have two images one for the default state and one for the selected state,
first i tried with xib,goin into the properties and changing the states and then selecting the proper images and when I build and run my code,On cliking the image doesnt change..
So I did this way through code
- (IBAction) handleButton:(id)sender
{
UIButton *button = (UIButton*)sender;
int tag = [button tag];
switch (tag)
{
case BUTTON_1:
if ([m_Button1 isSelected])
{
[m_Button2 setImage:[UIImage imageNamed:#"image.png"] forState:UIControlStateNormal];
[m_Button1 setSelected:NO];
}
else
{
[m_Button1 setImage:[UIImage imageNamed:#"image_pressed.png"] forState:UIControlStateSelected];
[m_Button1 setSelected:YES];
}
[self displaymethod1];
break;
case BUTTON_2:
[self displaymethod2];
break;
default:
break;
}
}
here the image changes when i click on it and i go to diffrent view..when i again come back to my first view,the button is still in selected mode..so How shall i fix this..
Waiting for your reply
I think is a bit simpler through IB.
When you add a regular Round Rect Button in IB you can modify its behavior by going to the Button section in the Attributes Inspector panel.
First select the images you want for it's default state by leaving the State Config in Default. There is an image and a background image properties for this. Once that is set, you can change the State Config to Highlighted and select the image you want to show when the button is highlighted.
NOTE: This is for xcode4.
when your view will appear then you have to initiate all the variable and UI property
in view will appear method. (not necessary in all cases solution is only for your requirement)
There you can set your button default state and image.
-(void)viewWillAppear:(BOOL)animated
{
[m_Button2 setImage:[UIImage imageNamed:#"image.png"] forState:UIControlStateNormal];
[m_Button1 setSelected:NO];
...
}