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
3
votes
2 answers

How can I add a "add" button at the end of the visible collection view in iOS

I am trying to add a button at the end of my collection view (of folders) to add a new cell (folder). The goal is to have always at the end a button to add new cells (folders). Here is what I am doing: 1st I return the number of items + 1 (to have…
Andrea.cabral
  • 338
  • 3
  • 16
3
votes
3 answers

Call function outside of class from UIButton

I have a function that I'd like to call when a button is pressed, but unlike anything I've done to date, I'd like to be able to reach it from any of several ViewControllers. I don't want to have to duplicate the same chunk of code in each…
Erik
  • 2,299
  • 4
  • 18
  • 23
3
votes
1 answer

UIButton also highlighting when cell is touched

I've a UIButton on my table cell that pops up (touchUpInside) a UIAlertView and asks the user if they want to delete the file associated with that cell. Otherwise, a touch on the cell itself highlights the cell then moves to the next level to…
Michael Morrison
  • 1,323
  • 1
  • 18
  • 30
3
votes
0 answers

UIButton in UIView inside UIScrollView does to receive touch events when outside original frame

I've been reading similar posts all morning, but could not find an answer to my problem. As title says, I have several UIButton-s in UIView that is a child of a UIScrollView. I set the contentSize for the scrollview, and I can scroll and see all…
Andy F
  • 59
  • 3
  • 5
3
votes
1 answer

Storyboard Max dimensions

I'm working on an iPhone app in Xcode 6 and I have set the constraints for my view. I want to ensure that a UIButton doesn't go off the page or lose its aspect ratio on extreme sized devices. UIButton is center on the view using constraints UIButton…
Marcus
  • 9,032
  • 11
  • 45
  • 84
3
votes
0 answers

How to set constraint of imageView and title label inside a UIButton with autolayout

I have a problem using autolayout with uibutton. What I want is make a button's image and its title 10 points gap, and image is on the right,while title is on the left.What should I do to achieve that? Appreciate for any suggestion!
John
  • 525
  • 3
  • 14
3
votes
2 answers

A long UIButton title label truncates in the center instead of on the right

I am testing the following code: username = @"addagkagalkjagjalggxxaklgjagjglkjag"; NSString *fullUsername = [NSString stringWithFormat:@"%@%@", @"@", username]; UIButton *usernameButton = [UIButton…
cdub
  • 24,555
  • 57
  • 174
  • 303
3
votes
6 answers

Find the indexPath of a button inside UITableViewCell when button pressed?

The code below correctly returns the cell: func findSuperView(sender:UIButton!) -> UITableViewCell { var superView : UIView? = sender.superview var foundSuperView : UITableViewCell! while superView != nil && foundSuperView == nil { …
3
votes
4 answers

Creating a Custom UIButton

I am looking to create a Custom UIButton (not subclass) progrmatically, I would like it to have a background image that will stretch as the UIButton's width increases. How would I do this?
Joshua
  • 15,200
  • 21
  • 100
  • 172
3
votes
2 answers

Detect what is the location of the tap/press inside UIButton inside sender action method

I have a UIButton stretched to the size of the view (covers the view/screen). I have set a Touchdown action and I need in this action to find out what is the location of the tap/press on the button (get x and y coordinates). Is it possible?
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
3
votes
1 answer

Increasing integerValue of UITextField

The is the completion code of the code that animates squareOne. When it is clicked it becomes hidden. If the index of the image squareOne uses, is the same as icon and if squareOne is hidden, then the animation repeats. (This is the condition I want…
Minestrone-Soup
  • 399
  • 1
  • 16
3
votes
1 answer

UIButton action is not called when added as a subview in UIView with setTranslatesAutoresizingMaskIntoConstraints(false)

I have a UIButton created programmatically, added the "pressed" function for the event "UIControlEvents.TouchUpInside". But the "pressed" method is not called when added as the subview of an UIView. Code is provided below for your reference.…
kaneyip
  • 1,237
  • 1
  • 17
  • 21
3
votes
0 answers

Changing frame of a UIView doesn't update its frame in its parent's subviews array. Hence the position doesn't changes

I am fairly new to IOS App Development. I have a view with 2 UIView and 1 ScrollView. One of the UIView is a footer which I want to be animated in such a way that it will hide/show to/from out of the screen based on some condition. However when I…
thrust
  • 225
  • 1
  • 8
3
votes
2 answers

Objective C. What's wrong with this UIButton image?

I have a set of UIButtons mapped out in IB. I want to randomly add images to a few buttons for each round of an education game. You can see some images stashed at the top of the page: As you can also see, the images in the buttons are blue. So,…
ICL1901
  • 7,632
  • 14
  • 90
  • 138
3
votes
0 answers

UIButton Unwanted Vertical Padding With Autolayout

For some reason, my buttons have this strange small vertical padding that I can't get rid of. I'm using autolayout so sizeToFit doesn't do anything. Is there any way to get rid of this padding? I've tried increasing the content hugging priority…
Eric Gao
  • 3,502
  • 2
  • 19
  • 29