Questions tagged [uibutton]

UIButton is a subclass of UIView for displaying buttons in iOS. It implements the target action paradigm to send events to the controller layer.

A UIButton intercepts touch events and sends an action message to a target object when tapped. Methods for setting the target and action are inherited from UIControl (). This class provides methods for setting the title, image, and other appearance properties of a UIButton. By using these accessors, you can specify a different appearance for each button state:

  • UIControlStateNormal,
  • UIControlStateHighlighted,
  • UIControlStateDisabled,
  • UIControlStateSelected.
  • UIControlStateFocused.

Resources:

11252 questions
38
votes
2 answers

How to click a button programmatically?

I have 2 view controllers which should be swapped according to userinput. So, I want to switch the views programatically based on the input I get from a text file. Algorithm : if(input == 1) { Go to View Controller 1 } else if(input ==2) { …
Coding4Life
  • 619
  • 2
  • 7
  • 14
38
votes
10 answers

Use UIBarButtonItem icon in UIButton

UIBarButtonItem has multiple icons available. Is it possible to use the icon which appears after setting its identifier to 'trash': with an UIButton? There is no straighforward method to do that like setting the identifier or style.
ZviBar
  • 9,758
  • 6
  • 25
  • 30
37
votes
3 answers

iOS - add contact into Contacts?

Heyo! Is there a way how when a user taps a button it can add or update a contact into the actual Apple Contacts Book? Some festivals have email responses include a "name card" that the receiver can download and find in their contact book.
HowbeitGirl
  • 591
  • 3
  • 12
  • 21
37
votes
3 answers

Why shouldn't I subclass a UIButton?

I've asked a few questions on stack overflow about subclassing a UIButton, and a couple of people have informed me that I shouldn't subclass a UIButton. What are the negatives of subclassing a UIButton? And I know it's vague, but what are other…
SirRupertIII
  • 12,324
  • 20
  • 72
  • 121
36
votes
12 answers

How to remove UIButton selected background color?

I am looking for a solution to this problem that does NOT require using images/PNGs. I am looking for a way to remove the UIButton's blue background color when it's in selected state, and I just cannot find a way to do that without using images. I…
TommyG
  • 4,145
  • 10
  • 42
  • 66
36
votes
5 answers

UIButton won't gray out

Isn't UIButton supposed to become grayish/grayer when enabled=NO ? I have a simple UIButton on a blackbackground (no custom images, no custom nothing, just dragged it with IB and changed size and title). And when I set it programatically to become…
xfze
  • 765
  • 1
  • 9
  • 24
36
votes
7 answers

UIButton in UITableViewCell

I have a UIButton with an image inside of a UITableViewCell. When the cell is being highlight, the button is also entering the highlighted state (i.e. a darker shade of the image), regardless of whether the user is clicking within the bounds of the…
NRaf
  • 7,407
  • 13
  • 52
  • 91
36
votes
3 answers

Objective C Setter overriding in Swift

I need to override the setter of UIViews highlighted property in my custom UIButton subclass ; Objective C @property(nonatomic,getter=isHighlighted) BOOL highlighted; overridden like this - (void) setHighlighted:(BOOL)highlighted { [super…
Ezimet
  • 5,058
  • 4
  • 23
  • 29
36
votes
7 answers

iPhone/iPad UIButton TitleLabel text not appearing

I created a grid of buttons. The following code creates the buttons and displays them, but there is no text on the button. Is there a setting I am missing? (Obj-C replies are fine, I'm bi-lingual) RectangleF frame = new RectangleF (X + 3, Y + 3,…
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
36
votes
4 answers

No Round Rect Button in Xcode 5?

Is drag and drop of round rect button no longer available in Xcode 5? I can't seem to find it in the Interface Builder. I was guessing that this is one of the changes in iOS 7, but I just wanted to make sure.
juminoz
  • 3,168
  • 7
  • 35
  • 52
36
votes
6 answers

UIButton titleLabel not displaying

I have seen a bunch of similar questions, but noone got the answer I am looking for. When I use this code to make a UIButton and set it's titleLabel, the UIButton appear, but the titleLabel won't appear. UIButton *button = [[UIButton alloc]…
Peter
  • 1,848
  • 4
  • 26
  • 44
35
votes
2 answers

UIButton TouchUpInside Touch Location

So I have a large UIButton, it is a UIButtonTypeCustom, and the button target is called for UIControlEventTouchUpInside. My question is how can I determine where in the UIButton the touch occured. I want this info so I can display a popup from the…
Andrew
  • 3,874
  • 5
  • 39
  • 67
35
votes
1 answer

UIButton - text truncated

I've created a wide UIButton with Interface Builder (Xcode 4), added in a dummy 5 character title (e.g. Click) and then changed the title text programmatically later. Odd thing is the width of the title text seems to remain the same so, if I use a…
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
35
votes
3 answers

UIButton inside UIImageView does not respond to taps

I have a scroll view, which has an image view with an image as a subview, and the image view has a UIButton as one of its subviews. The problem is, I am not able to click on the button. I can SEE the button, but I cannot tap on it. Can someone tell…
Ravi
  • 7,929
  • 6
  • 38
  • 48
35
votes
3 answers

Subclass UIButton to add a property

I'd like to subclass UIButton to add some properties that i need (not methods... only properties). Here the code of my subclass: //.h----------------------- @interface MyButton : UIButton{ MyPropertyType *property; } @property…
MatterGoal
  • 16,038
  • 19
  • 109
  • 186