UIButton Not Hiding - ios

I use IB and have properly wired up my buttons. I have verified they are properly wired, as some IBAction methods will have buttons hide properly. The issue I have is hiding the UIButtons when it first loads the app. In viewDidLoad I set the button property to hidden, but it doesn't hide it. Thoughts?
- (void)viewDidLoad {
stop.hidden = YES;
play.hidden = YES;
[activity startAnimating];
[super viewDidLoad];
}
After more debugging, the stop button hides but not the play.

It's hard to tell even from the code you posted why this is happening, The best guess will be that somewhere in the next lines of code you set it back to visible = YES mistakably. I would check if there is a method that shows the button that is called before it is needed.
BUT
If the initial state is hidden for your buttons. why don't you simply hide them on IB interface?

Try this
Remove outlet run the code ,test weather it works fine
Remove outlet,add hidden property via IB and run it again and test if it is seen properly.
If it works fine the problem is with code written.
Check the hidden property written via code

Related

UITextField and UIButton are not clickable

I am implementing simple UI for URL checking. For this, I used textField and button objects.
When I run the program first time, textField and button will work fine but when I click on the done button on the keyboard then the keyboard is dismissed. Now I want to edit the textField and when I am trying to click on textField it is not clickable or not showing the keyboard. same thing happened to the button, next button is also not clickable.
Here is the code I wrote for the button action
- (IBAction)urlNextButtonAction:(id)sender {
[self.urlTextfield resignFirstResponder];
[SVProgressHUD showWithStatus:#"Verifying URL"];
[self URLValidationMethod];
}
Please check this video you will understand the problem very easily
This is the ViewController screenshot from storyboard
There could be several issue with this..
Check either Textfield delegate might not be or properly set.
Try to debug textfield delegate methods are they working.
it would be helpful if you show what you have written in keyboardShouldReturn method.
It seems like the problem is with the SVProgressHud. You should remove it as soon as you task is completed by calling [SVProgressHud dismiss] or else it will block the UI.

.hidden = YES working but .hidden = NO not working

I have a UIImageView with a custom class in a table cell that also uses a custom class. The UIImageView is connected as a property of the cell's custom class.
The UIImageView has a UITapGestureRecognizer that calls method tapped: I'm passing the cell as the UIImageView's delegate and trying to unhide another view of cell using cell.theOtherView.hidden = NO Strangely, to hide .hidden = YES works, but to unhide isn't working.
It's hard to know what's going on without seeing the code you're working with (for example, your code might never actually be reaching the line that sets the view to be hidden), but as MattyAyOh suggested, it's worth trying
[cell.theOtherView setNeedsDisplay];
after you set cell.theOtherView.hidden = YES;. This will force the view to redraw itself.
My guess is that once it's hidden, it no longer received the Tap gesture. Try using cell.theOtherView.alpha = 0.0.
you should register your object to .h file first, then you could use hidden function

Can't get UILabel to display from boolean condition

I can't for the life of me figure out why this won't work. I'm trying to display a label after determining a boolean condition. No matter what I do, the label won't display. So in a pathetic desperate attempt, I put the code to display the label inside a button event to force it to display. Now it works perfectly (from the button click). But it still won't work from the boolean condition!
This is in viewDidLoad (note that the 'true' is just to isolate where the fault is):
if (true) [self showSubscribeLabel];
This is from the button click:
- (IBAction)askUserToSubscribe:(id)sender {
[self showSubscribeLabel];
}
-(void) showSubscribeLabel {
NSLog(#"here");
self.subscribeLabel.hidden = NO;
[self.view bringSubviewToFront:self.viewUnauthorized];
}
I see the output here when the controller loads and then again after clicking the button. What am I doing wrong? Thanks!
You should move your test and method invocation to viewWillAppear - often things aren't fully initialised in viewDidLoad. Having the code in viewWillAppear will also ensure that the condition is evaluated every time the view controller appears (such as when another view pops off a navigation stack) rather than when it is loaded for the first time.

UIPicker Not Showing Up

I have a UIPickerView that I made programmatically but everything I made in interface builder and the picker wont show up once I run the app. It worked before I made the background in IB (which is a UIImage).Everything else shows up.
- (void)viewDidLayoutSubviews(viewDidLoad)
{
[self.view bringSubviewToFront:picker1];
[self.view sendSubviewToBack:backgroundImage];
[backgroundImage addSubview:picker1];
}
I've tried all these.My brain is dead and I really just need help. Why wont my UIPickerView show up. All the needed data is there it worked before I put a background on it.Can anything be done ?
Make sure that your data delegates is connected to the view. You can do this by going to the storyboard and clicking the Files owner and connecting the referencing outlets to the view.

Adding a custom UIButton and action to a view in window app delegate (ios)

I am working on a tab bar application which needs a global title bar with a setttings button attached. I have achieved adding an imageview to the main window, then a label, another image, and finally a button. However, I cannot get this button to fire an action. it is set up like this:
[settingsButton addTarget:self action:#selector(settings) forControlEvents:UIControlEventTouchupInside];
Then the action defined like:
-(void)settings{
NSLog(#"please do something");
}
However nothing happens, the image doesn't even change like it is being pressed. Can i not define buttons in the app delegate this way? is it because the target is not something that is control based? i tried different targets but i must not fully understand what setting a target is. thanks for any help.
P.S.- i tried setting up the method like so as well:
-(void) settings:(id)sender{
}
and calling it by replacing the action with #selector(settings:) to no avail. Thank you.
I solved it. I forgot I changed the view behind the button to a UIImageView. I can't believe I didn't think of this before since this same issue cost me 2 hours the other day. When you have an imageView always remember to set this flag if you want stuff on it:
(someImageView).userInteractionEnabled = YES;
Hopefully I save someone an hour or two of needless headaches.
P.S. Thanks for the speedy comment !

Resources