UIButton title set in Storyboard is missing when run - ios

I am quite new to iOS development and I encountered a problem when I was trying out a simple calculator tutorial. For some reason, the "0" and "=" does not appear on the iOS simulator while it appeared perfectly fine on the user interface shown on XCode.
Any idea on how to resolve this problem?
Thanks! =)

Just set the Style value to "Default" from "Attributes Inspector" tab as shown in the image below.
Now you should see the Font, Color and other attributed properties are back :)

In my case the button title disappeared, when I made changes to its attributes. Changing the Button title back to 'plain' and back again to 'attributed' made the text visible again.

One possibility could be that you accidentally set the titles of those two buttons on a control state other than default or UIControlStateNormal.
The buttons in your screenshot are in a state called UIControlStateNormal because they aren't being tapped or disabled. Select the buttons and make sure the 'State Config' option in the Attributes inspector is set to 'Default' when you're setting your title in Storyboard.
EDIT
Autolayout sometimes causes unintended behavior like this. If you aren't relying on Autolayout and don't plan to, you can turn it off in the File inspector. If you are relying on Autolayout, you'll have to write some code to undo the unintended behavior it's causing.

Related

"Print" & "Cancel" disappeared from Printer Options in UIActivityViewController

The buttons are still there and function fine, however as you can see they are completely invisible. Adjusting font colors and navigation bar colors had no effect. I have been trying to resolve this for months and despite reading Apple's documentation, I am unable to even see where you would change what I assumed to be a system wide function.
So to help narrow down this issue I created a simple navigation controller with a print button. If I put these both on the Login storyboard (the first storyboard) it works perfectly fine. If I put it on Main.storyboard (the second storyboard) it doesn't work.
If I change my project settings to make Main.storyboard the first storyboard it works. Leading me to believe the issue is in my FirstViewController.
You can set the color of the print and cancel button
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIToolbar.self]).tintColor = UIColor.green
After narrowing down the problem to the first view controller I discovered the tint was set to Clear Color (ie Alpha is 0). Fixing this resolved the problem in the rest of the app. I am surprised a setting in a view can propogate to the rest of the app and overwrite all of the other views in the process. Perhaps apple set the first view to determine the colors for system pop ups etc.

UIButton not showing any effect when tapped?

I am using Xcode 9.4.1 and I have added a UIButton in storyboard in a new project. Have changed the button to custom and have set constraints.
My problem is there is no change in button appearance when it is tapped. there has always been a default change in uibuttons appearance when it is tapped in earlier projects.
Is it only with me or its a general thing with new xcode?
You can try setting UIButton's selected state properties.
just check state of UIButton in Attributes Inspector set it enable then check type it should be system and not showing then once click on drawing = Show touch bar on Highlight then run your project and see when click is there any effect or not. Hope this is work fine for you.

Swift UIButton - How to remove underline?

I have problem when in iOS settings is enabled this setting "Button Shapes"
It causing this underline in application (first picture with enabled setting, second without)
Any idea how to programatically or in storyboard disable it?
I tried attributed text but I get same result :(
I'm newbie in Swift.
Thanks for help!
It's not a problem. You should not make any attempt to counter any accessibility changes set by the user. They are there for a reason.
This is an answer by user4291543 from this question Remove underline on UIButton in iOS 7
[yourBtnHere setBackgroundImage:[[UIImage alloc] init] forState:UIControlStateNormal];
I found this answer works with SWFrameButton
And for all the others saying "Don't Do This", SWFrameButton is a very good example of when you would want to do this. I also think the OP's situation is a perfectly valid scenario as well...
I totally agree with #maddy's comment:
It's not a problem. You should not make any attempt to counter any accessibility changes set by the user. They are there for a reason.
But I did stumble on a way to accomplish the task at hand...
In addition to a UIButton, you'll also need to make a .png file that contains nothing (meaning the entire contents have an opacity of 0%). Go ahead and load that into your xcode project's assets.
Now go ahead and set the Button's Background to that image you just provided. (In my case, I called it clear) This will remove the underline from the button's text. However, now you can't see the boundaries of the button. This can be solved by changing the Background of the button's View. Go ahead and select any color for the View's Background property and now the background of the View visibly defines the button's boundaries. You're able to see this because your clear.png has an opacity of 0%.
see the Attributes inspector for UIButton here.
Rather than trying to defeat the underline by going to make a label perform some action via UITapGestureRecognizer, this allows you to still use a UIButton. Keeping inline with accessibility features to mark buttons for people that want to do that.
You could create a custom button class with a label (with clear color). If you set the text of this label instead it shouldn`t get an underline.
Are you sure you want to do that?
Apple added an accessibility feature to mark buttons for people that want to do that. Apple will probably reject your app because it defeats a system function meant to help the disabled.
I found the solution. All you have to do is set a picture as the background of the button. just pick a picture with the same color as the button you created.

iOS: How to disable Fading in and out effect of UIButton

First of all, sorry for the title and asking this incredibly question but I simply couldn't figure it out. Also, since it is not related to code, I don't have code to show
I am working on an app and using iOS7 and I created a button from IB, set its background image to an image I designed. Connected it with header and set its touch up inside action as an IBAction
Yet, here is my problem. Whenever I click on the button, as an effect the image fades half transparent. I do not want this default attribute. I checked all the states on IB (highlighted, disabled, selected) and couldn't figure it out.
If I create the same button programmatically, only the text color changes, however when I set the background image, image fades (perhaps to indicate the button being pressed). How can I remove this effect?
A bit late but I believe this would solve the problem
in the xib file, set the button's type to Custom.
My button was set to system and when pressed on, it shows transparency and has a little fade in effect. Once I changed it to custom this effect is gone.
This cannot be changed once button is created. only in xib or when the button is first created.
have you tried this one yourButton.adjustsImageWhenHighlighted = NO?
If you set same background-image/background-color for every buttons states in IB (highlight, disable, selected) you will not get any fading in UIBUtton when you press it. You can set text color for every states also. If needed you can set different colors for every state and check the press action.
Hope the answered you expect. Thanks
Storyboard Solution
1:set button type to custom
2:uncheck "Highlighted adjusts Image"
If you want fading in & out effect your UIButton Type Should be a system, not custom.

Editing toolbar in Xcode 4.6 - unable to add Bar Button Items

I am attempting to add a toolbar as an input accessory, and as such have added it via xcode storyboard editor to the view controller (and not within the view). This was as specified in this tutorial(which seems to be written for an earlier version of xcode): reference
My issue: "8.) Now we need to open the toolbar item itself. Double click Toolbar in the document window."
This is no longer valid behavior in Xcode 4.6 it appears, so I ask you: how do I add button items to a toolbar? I would prefer to avoid doing it programmatically (Still reasonably new to xcode development and normally make my GUIs with storyboards) but if I have to, I have to.
Many thanks!
If you're doing what I think you are doing, adding UIBarButtonItems to a UIToolbar, then you simply drag a Bar Button Item out to the toolbar.
However, I would assume that what they mean when they say 'double-click' is not what people normally think of when they think double click. Try double clicking slowly this often does the trick.
Found the issue - it was appearing behind the UIView. However you dont ever need to graphically interact witha toolbar, you can just drag-and-drop controls onto it in the sidebar. If there is a need for more info on this message me or vote up.

Resources