UIButton hidden but working - ios

I am doing an application , using ARC. I add a button to the navigation controller as a subview and then remove it. It works fine on simulator but on device, after using for a long time, the buttons are hidden , but on touching on that area, it responds.
Could it be some memory issue?

Wherever you place button.hidden = YES, also place button.enabled = NO.

Related

How to make the buttons visible on simulator?

I'm using Xcode 5.1.1. I recently added a background image to my application but the buttons on the view controller aren't visible. When I remove the background image, the buttons become visible again. How to handle this?
If you are not checking the view hierarchy, then do one thing create outlet of you button and then write following code in viewDidLoad.
[self.view bringSubviewToFront:yourButton];
I don't know if you were used xib...
If you are using xib in your project, giving a background image for your button will more easy.
Place a button anywhere you want. Then go to attributes inspector on the right hand side. There you can find a field for changing your background image. Just give the name of your image.
Hope it will helpful for you

Button Disable Xcode 5.1.1

I am getting a very weird issue while disabling a button in Xcode 5.1.1 and iOS SDK 7.1.
My button gets hidden when I disable the button in - (void)viewDidLoad or - (void)viewWillAppear:(BOOL)animated or in the nib.
The same code is properly working for iOS 7.0 and below.
myButton.enabled = NO;
Is this an Apple bug?
I had tried in different projects also but result is same.
I am using it Xcode 5.1 and it works perfectly on iOS 6 to iOS 7.1.
possibility is:
check whether the button is system or custom. it should be custom always.
Try making the button as myButton.enabled = YES; and see whether the button hidden in iOS 7.1.
Then check whether in nib file, you have set clear color for disabled state of the button.
May be your button is placed below another ui object (i.e. UIView), so it is hidden and disabled. If another view's user interaction is enabled, and this view happens to be above the button, then touch event is taken over by that view. Another issue can be that your button is beyond super view's bounds and this super view has clipToSubview enabled.
Actually the problem exists while i am setting the image. I am setting the image of each button using SpriteSheet. The image gets added dynamically after slicing and resizing in background. So whatever the state of button is it just set's the image of Disabled and normal state.
Now to resolve this i checked whatever the state of button it just sets its
if (myButton.state == UIControlStateDisabled)
{
myButton.enabled = YES;
[myButton setImage:returnImage forState:UIControlStateNormal]; // return Image is the image which i get from sprite sheet after slicing and resizing.
myButton.enabled = NO;
}

iOS TableView Form Navigation

When using Safari and filling out a form, there are three buttons conveniently located at the top of the keyboard labeled Previous, Next, and Done. Is there a keyboard setting that can enable those or do you have to create and program these buttons manually?
I've had some success using this library:
https://github.com/simonbs/BSKeyboardControls
There is no default property of keyboard provided in ios. You need to add toolbar for that. Then you add previous , next or done UIBarButtons in the toolbar.
When keyboard appears toolbar is also displayed above it using some animation or directly same way when it hides/disappears you have to hide the toolbar also using animations or by changing it positioning in view.
Hope it helps you.
XCDFormInputAccessoryView is an accessory which contains the features you needed. It is easy to use. Here is how it looks with keyboard

Button remains visible when disabled

I have created a custom button in IB which performs a play video function for me. But sometimes when the video is not available I want to have the button disabled & invisible.
the button is linked to the code by having dragged the IBOutlet.
so when I do [playButton setEnabled:NO] it gets disabled, but it's still visible, although becomes transparent. I need it completely disappeared. Any ideas?
Set playButton.hidden = YES to hide it.
Disabling only prevents user interaction

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