Hiding and revealing UIButtons - ipad

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

Related

hide and show left navigation bar button on demand in iOS-7

I added my left navigation bar button using the storyboard. but I want it to hide when I first load the screen. And then in response to something else, I want it to show. The navigation bar has a method for hiding the back button. But there is no method for hiding/showing the left button. Is there a simple way for doing this? Or do I have to use two methods: the hiding method creates an empty button and the showing method creates the correct button? The button in question is just the Add template that iOS provides (which makes it easy to just use the one in the storyboard than to create my own).
Here is how I solved it
-(void) hideAndDisableRightNavigationItem
{
[self.navigationItem.rightBarButtonItem setTintColor:[UIColor clearColor]];
[self.navigationItem.rightBarButtonItem setEnabled:NO];
}
-(void) showAndEnableRightNavigationItem
{
[self.navigationItem.rightBarButtonItem setTintColor:[UIColor blackColor]];
[self.navigationItem.rightBarButtonItem setEnabled:YES];
}
Swift version of #learner answer
func hideAndDisableRightNavigationItem (){
self.navigationItem.rightBarButtonItem?.enabled = false
self.navigationItem.rightBarButtonItem?.tintColor = UIColor.clearColor()
}
func showAndEnableRightNavigationItem(){
self.navigationItem.rightBarButtonItem?.enabled = true
self.navigationItem.rightBarButtonItem?.tintColor = UIColor. blackColor()
}
Here is what I did. On the initial screen I wanted to hide the navigation bar:
self.navigationController.navigationBarHidden = YES;
On the second screen I wanted to show the navigation bar so I set:
self.navigationController.navigationBarHidden = NO;

Making image view disapear and re appear over the view controller

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.

Toggle Searchbar View using UIScrollView

I have a search bar embedded above a tableview which is visible as soon as the view is opened i want it to be hidden when the page loads and on click of the search button (Bottom left corner) i want the searchbar to get animated from top. I have read that this can be done using UIScrollview, but none of the tutorials have been able to help me.
For
1)I want it to be hidden when the page loads and on click of the search button
In your search button clicked...
if(self.searchBar.isHidden)
{
[sender setSelected:YES];
self.searchBar.hidden=NO;
[self resetFrame:tableView toFrame:CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y+44, tableView.frame.size.width, tableView.frame.size.height) withDelay:0.5];
}
else if(!self.searchBar.isHidden)
{
[sender setSelected:NO];
self.searchBar.hidden=YES;
[self resetFrame:tableView toFrame:CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y-44, tableView.frame.size.width, tableView.frame.size.height) withDelay:0.5];
[self.searchBar resignFirstResponder];
}
-(void)resetFrame:(UIView *)view toFrame:(CGRect )frame withDelay:(float)delay
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:delay];
[view setFrame:frame];
[UIView commitAnimations];
}
}
Just add the above when you click search button or if want it to be hidden when page shows add it in the viewWillAppear method
2)i want the searchbar to get animated from top.
Add the searchbar to the view by making its y axis below 0 example -100 and once page loads set its actual frame use resetFrame method to bring your search bar from top

UIScrollview remove space between hidden field

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.

Hide one view and unhide another upon touching a button

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.

Resources