FAQ Database Discussion Community


How to make a double line border UIButton?

ios,swift,uibutton,border
I'd like my buttons to have a double line border, like in the image. Is there a way of doing it programatically? ...

Custom UIButton Swift 2.0

ios,swift,uibutton,ios9
I am trying to convert my project to Swift 2.0. I have a custom UIButton that is now causing an error when I try to build. My code is: var myButton = MyCustomButton.buttonWihType(.Custom) as UIButton This is working with my project in Swift 1.2 but now does not work. The...

Swift - update UIButton image from last photo in roll

swift,uibutton,camera-roll
I am trying to use the last image from the camera roll as the background image for my UIButton. When the view loads up the button shows the last photo correctly. But when I snap a picture the background image in the UIbutton is not updated. Here is the code...

Issue with using RGB colors in IOS

objective-c,ios7,uibutton,xcode6,uicolor
I want to use RGB color to set set background color of UIButton. I have lots of UIButtons so I decided to make a custom class.But when I try to use colorWithRed I am getting error. First Code: [self.layer setBackgroundColor:[UIColor colorWithRed:60/255.0f green:146/255.0f blue:180/255.0f alpha:1.0f]]; Error Second Code self.layer.backgroundColor = [UIColor...

Will handling UIButton touch event inside a UITableViewCell subclass violate MVC?

ios,objective-c,uitableview,model-view-controller,uibutton
There is a UITableViewCell subclass with a UIButton inside. A web call should be made when the button is pressed. The question is whether I should set the action in the controller, or can the action be set within the UITableViewCell subclass? Will the second option violate MVC pattern?...

Change UIButton type in subclass if button created from storyboard

ios,swift,uibutton
If I create a UIButton in Storyboard and assign its Class to be a subclass I made (HighlightTappedButton), is there a way in the subclass to change the buttonType to Custom? I know I can just change the type to Custom in storyboard, but I don't want to have to...

How to dynamically add an action to a UIButton

ios,swift,uibutton
I noticed I had a lot of functions to dynamically add buttons in one of my view controllers, which clearly goes against the DRY principle. To fix this, I wrote a hit-everything configureButton function: func configureButton (button: UIButton, action: String, title: String, pos: [CGFloat]) { button.addTarget(self, action: action, forControlEvents: UIControlEvents.TouchUpInside)...

Set custom attribute on button

ios,swift,uibutton
How can i set custom attributes on an button that is programmatically created? I have this code to create an button: var btn = UIButton(frame: CGRectMake(CGFloat(7 + add), 565, 39, 55)) btn.setTitle(String(Array(shuffledWord)[i...i]), forState: UIControlState.Normal) btn.addTarget(self, action: "btnPressed:", forControlEvents: UIControlEvents.TouchUpInside) btn.tag = 7 + add; I can give some value to...

Change text color of UIButton in CalloutAccessoryView

ios,swift,uibutton
I use this code to create a UIButton in my CalloutView. var button = UIButton.buttonWithType(UIButtonType.System) as! UIButton button.frame = CGRectMake(100, 100, 100, 50) button.backgroundColor = UIColor.redColor() button.setTitle("No", forState: UIControlState.Normal) button.addTarget(self, action: "Action:", forControlEvents: UIControlEvents.TouchUpInside) anView.rightCalloutAccessoryView = button How can I change the text color of UIButton?...

How to update UI with WatchKit?

ios,uibutton,uilabel,watchkit
I created a sample watchkit app and I dragged a UIButton and UILabel into the storyboard app scene. I was able to hook up the UIButton to the interface controller and got it to update the UILabel. But the label.text was not reflected in the simulator. Nothing changes. Do I...

iOS: Button backgroundImage not changing in Annotation Callout View

ios,uibutton,mkmapview,calloutview
I have a MKMapView with a number of annotations representing stores. When the user taps on an annotation I present a custom annotation view. This view contains a favourite button, that adds the store to the user's favourites. If the user presses this button it changes its backgroundImage property to...

UIButton creating error - “unrecognized selector sent to instance”

swift,uibutton
I have added a button to my view using this code, however it comes up with the error "unrecognized selector sent to instance" and crashes the app. Does anyone know why this is ? Many thanks! let button: UIButton = UIButton(frame: CGRectMake(100, 400, 100, 50)) button.backgroundColor = UIColor.clearColor() button.setTitle("go Back",...

respondsToSelector returns YES for “setTitle:” on UIButton but there is no such selector

ios,objective-c,uibutton,respondstoselector
So i'm using respondsToSelector: and most of the time it works fine. But there is one case in wich i get wrong result: UIButton* button = [[UIButton alloc] init]; if([button respondsToSelector:NSSelectorFromString(@"setTitle:")]) // returns YES { // try to call "setTitle:" } respondsToSelector: returns YES but there is no setTitle: selector...

Multiple Buttons, But only one pressed at a time

ios,objective-c,uibutton
I've been looking through the site and I've been unable to find anything that answers my question. In my app i have a modal dialog that displays a UICollectionView that uses a custom cell and only contains a UIButton. I have set the buttons up to be selectable rather than...

why is my app stalling when the play button is tapped

ios,swift,uiviewcontroller,uibutton,xcode6
import UIKit class ViewController: UIViewController { var timerCount = 5 var timerRunning = false var timer = NSTimer() func shuffle<C: MutableCollectionType where C.Index == Int>(var list: C) -> C { let c = count(list) for i in 0..<(c - 1) { let j = Int(arc4random_uniform(UInt32(c - i))) + i swap(&list[i],...

Delete a row from other UIViewController with a UIButton

ios,objective-c,uitableview,uiviewcontroller,uibutton
I have a question, I have aUITableViewController which have a list with something, When I push on a row it send me to anotherUIViewController. I implemented this with prepareForSegue method also I put - (void)tableView:(UITableView *)tableView commitEditingStyle: when I swipe a row is deleting. Everything is working perfect. Now, my...

Swift - How to properly architect buttons in MVC?

ios,swift,uiview,uibutton,segue
I had wrote a block of code which made a UIButtons in a UIView with a segue action all in the ViewController file. The segue action allows the user to press on the a UIButton and pushes a new UIView with the title of that button on it. This worked...

UIButton with target:self not being sent to self?

ios,uibutton,action,targets
I'm creating a new UIViewController (call it MyViewController), and adding the view (MyView) as a subview of a TableViewCell. Within MyView , there's a button. That button is created programmatically during MyViewController's init, as such: -(id)initWithFrame:(CGRect)frame { self = [super init]; if(self) { [self.view setFrame:frame]; _yesButton = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width-150,...

Setting layer out of layer in UIbutton?

ios,objective-c,uibutton,uiimage,calayer
i want this type of button i have tried pictureBtn which is UIbutton ,i gave it a 5 pixel clear color corner radius and add a picture like camera below but last outer white line how to deal with this can anybody have ideas or something like control. ...

Create a few UIButton programmatically and reconstruct the object later using tag?

ios,objective-c,uibutton
I am creating a few buttons programmatically, similar to: for( int i = 0; i < 5; i++ ) { UIButton* aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [aButton setTag:i]; [aButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; [aView addSubview:aButton]; } And that I can implement the function of the button this way so that I know...

UIButton not Blinking on Touch

ios,objective-c,uibutton
I have a UIButton, created programmatically, inside a UIView (no other levels to the hierarchy). The button does respond to the touchUpInside event properly, but, for some reason, the text isn't exhibiting its normal "blink" behavior when touched. I'd like to get that back, if anyone knows what could cause...

Create a rating view in IOS objective c

ios,objective-c,uibutton,rating
I want to create following rating views shown below. How is it possible to do it I have got 3 conditions.I have got label in top and below that are stars and at the end there is TextField. Good,Amazing,Horrific is set according to number of stars. When there is 1...

Update button image on swift 2.0

ios,uibutton,swift2,xcode7
When I try using this solution to update an UIButton image (Xcode 7 beta 1), it gives me this error: "Cannot invoke 'setImage' with an argument list of type '(UIImage?, forState: nil)'" Here's the code: if counter % 2 == 0{ playButton.setImage(UIImage(named: "pause"), forState: nil) } else if counter %...

UIButton – what is the default image highlight color

ios,uibutton,uibarbuttonitem,back-button,uicolor
Is there any approach how to create from some color (let's say it's [UIColor redColor]) the default highlighted shade of this color (some kind of dark red color in this case). In my case, I have a UIButton (inside of UIBarButton) and I would like to setup the titleColor for...

Prevent iOS from darkening image of pressed button

ios,uibutton
I assign two separate images for UIControlState.Normal (button released) and UIControlState.Highlighted (button pressed). Both images are accepted, however, while the released image is displayed as is, the pressed image appears darker and maybe more transparent than the original image. It there a way to prevent iOS from modifying image of...

Is it possible to get button title from IB in class?

ios,swift,uibutton
I have several buttons with titles 0 - 9 and in my custom UIButton class I want to be able to use a switch to check the button title. The buttons are created in the storyboard. The UIButton class looks like: protocol NumpadDelegate: class { func changeValue() } class NumpadButton:...

UIButton text not staying changing

ios,uitableview,swift,uibutton
I am developing a simple iPhone app in Swift I have a customUITableViewCell. In the cell I have a normal UIButton with text of "Hello World". In my code for the custom cell, I have the following function: @IBAction func buttonAction(sender: AnyObject) { if likeButton.titleLabel?.text == "Hello World" { likeButton.titleLabel?.text...

How to customize uibutton's class in Swift?

ios,swift,uibutton,subclassing
I have different types of buttons in my app, and I would like to have a way so that I don't have to write the code to format the attributed labels or setup insets and background image in interface builder for each button on every view controller. I was thinking...

UIButton not showing highlight on tap in iOS7 - Swift

ios,swift,uibutton,highlight
From this post they said that it is kind of a bug in ios 7 and 8 - Button in UITableViewCell does not change to highlighted when tapped. Here I post one answer for this in Objective-C: Create a custom UITableView subclass and custom UITableViewCell subclass. Use this sample UITableView's...

How to increase height of UIButton image without moving button

swift,uiview,uibutton
I have added a UIButton to storyboard and then added my image to the button. What I am looking to do is when you tap on the button the height increases slightly and then the button decreases in height by about a quarter. @IBAction func StopsClick(sender: UIView) { //Get the...

Centralise the title of UIButton as show in the Image Below Swift

ios,swift,uibutton,text-alignment
I want to show Button title like this but my output is comming like this even after centralising the title frmbtn is the outlet of button And the Code I am Using for this is frmbtn.setTitle("From Station\nSTN\nSTATION NAME", forState: UIControlState.Normal) frmbtn.titleLabel!.numberOfLines = 3 frmbtn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center And Can we put...

Getting An Item from IBOutletCollection in Swift

ios,swift,uibutton,iboutletcollection
I'm getting an error as "Type of expression is ambiguous without more context" Here is my code @IBOutlet var customerDashboardButtons:[NSArray]? var predicate = NSPredicate(format: "SELF.tag == %d", tag) var filteredButtons = customerDashboardButtons!.filter { predicate.evaluateWithObject($0) }; if 0 < filteredButtons.count { var button = customerDashboardButtons!.first button.hidden = true // getting an...

Strange behavior when adding UIButton to UICollectionViewCell

ios,objective-c,uiimageview,uibutton,uicollectionviewcell
I'm trying to add aUIButton to aUICollectionViewCell. The main purpose of the button is to let users to select their favourites. When they click on theUIButton, the UIButton will display a glowing star image, showing that the item has been picked as favourite. Click on the UIButton again, and the...

Change color of the UIButton title navigation bar

swift,ios8,uibutton,navigationbar
When I create my navigation bar, I can place in left item, right item and in the title view, three buttons but only the left and right item have an animation and I can't change the color of the title button. The creation of the buttons in the navigation bar...

UIButton not highlighted on border

ios,objective-c,uibutton,uigesturerecognizer
I create a UIButton programmatically using the following code: myButton = [UIButton new]; [myButton setImage:[UIImage imageNamed:@"myButtonNormal"] forState:UIControlStateNormal]; [myButton setBackgroundImage:[UIImage imageNamed:@"myButtonBackgroundNormal"] forState:UIControlStateNormal]; myButton.alpha = MY_BUTTON_ALPHA; [myButton addTarget:self action:@selector(myButtonSelector:) forControlEvents:UIControlEventTouchUpInside]; [self.parentViewController.view insertSubview:myButton atIndex:10]; Now the problem I am having is with...

iOS UIButton title keeps reverting in UITableViewCell

ios,uitableview,uibutton,interface-builder,uistoryboard
I am trying to set up a fairly simple Storyboard/Interface builder app with aUITableViewController, with two prototype cells. The first prototype cell displays information on the main UILabel and the second prototype cell contains aUIButton. I have connected the button'stouchUpInside action to some piece of code where I want to...

Removing image from button misplaces text

ios,objective-c,uibutton
When I remove the image of a button (by setting it to nil), it makes the text move to the bottom left of the button. Am I removing the image the wrong way or am I supposed to reposition the text after moving it? Or am I supposed to remove...

iOS UIButton click doesn't work

ios,objective-c,iphone,uiview,uibutton
I have an issue with iOS UIButton click handling programmatically. I have a UIButton: - (UIButton *)compareButton { if (!_compareButton) { NSString *title = TITLE; NSDictionary *attributes = TITLE_ATTRIBUTES; NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes]; _compareButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 20.0f, 100.0f, 44.0f)]; _compareButton.backgroundColor = [UIColor redColor]; [_compareButton setAttributedTitle:attributedTitle...

UIButton with single press and long press events swift

ios,iphone,swift,uibutton
I want to trigger two action on button click and button long click. I have add a UIbutton in my interface builder. How can i trigger two action using IBAction can somebody tell me how to archive this ? this is the code i have used for a button click...

Losing tap recognition after adding a UIScrollView under a UIButton

ios,uiscrollview,uibutton,uikit,uitapgesturerecognizer
I have two adjacent UIScrollViews, both partially covered by a UIButton with a tap gesture recognizer. They are added to the view in this order: Scrollview #1 Button Scrollview #2 (added by user interaction) Both scrollviews are z-positioned "behind" the button, but the button does not receive taps where it...

When building to mobile the size of fonts reduce and became very small

c#,user-interface,unity3d,uibutton,unityscript
Like I said in the title when i built to mobile the letter became too small. I think it is because phone has more pixel for his little screen. Well I tried to fix text by simply making text to images in photoshop. But how can I make InputFields text...

Why the UIButton is so big in a simulator?

xcode,swift,uibutton,uipageviewcontroller
I have a UIPageViewController and a UIButton under it. Here is the screenshot of my storyboard. When I build the app, the button is huge: All of my constraints were set automatically. I tried to specify the height, but it doesn't help. Any ideas? P.S. I'm using XCode 6.3. Edit:...

UIButton Multiple Labels Using UIControlStates

ios,objective-c,uibutton,uicontrolstate
I know with a UIButton, I can add additional UILabels as subviews: [myButton addSubview: myLabel]; And (at least, with the default title label) I can set its text color when tapped by using: [myButton setTitleColor:someColor forState:UIControlStateHighlighted] My question is, how can I implement this functionality for additional UILabels added to...

Xcode user location no longer working in newer version (Objective-C)

ios,objective-c,xcode,uibutton,mkmapview
I have a button which moves to the user's location. I declare it in ViewControler.h and then added the following code into ViewController.m: - (IBAction)userLocation:(id)sender { [_mapView setCenterCoordinate:_mapView.userLocation.location.coordinate animated:YES]; } This keeps leading me to the (0,0) coordinates. Is there something in the newer Xcode version that I need to...

How do I toggle hidden of a label while a button is pressed?

ios,uibutton,uikit,uilabel
I am trying to figure out how to only display a label while a button is pressed in OS. I know how to operate the touch events but I am not sure how to incorporate the UILongPressGestureRecognizer into this.

Objective C - Remove only UIButtons from superview

ios,objective-c,uibutton,shinobi
I am fairly new to objective-c and I have ran into an issue that I have had a hard time solving.. I am using ShinobiDataGrid and using their prepareCellForDisplay. To get text to display I would do this: if([cell.coordinate.column.title isEqualToString:@"Task"]){ textCell.textField.textAlignment = NSTextAlignmentLeft; textCell.textField.text = cellDataObj.task; } but for a...

Is there a way to use a UIButton for text in a countdown timer?

ios,objective-c,timer,uibutton,uilabel
I'm a new in iOS Development and I am writing an app that has a countdown timer. I want the user to be able to tap on the time to set it so I used a UIButton as that seemed the easiest thing. I've seen questions on this site about...

How to segue to a new UIViewController at the end of an array count

ios,arrays,swift,uibutton,segue
Let me first explain the concept. I ask the user 3 questions, which are stored in an NSArray. There is one UITextField which the user will use to write all 3 answers to the questions. What I would like to happen, when all three questions have shown from the array,...

UIButton setAutoresizingMask not working programatically

ios,objective-c,uibutton
I'm adding a UIButton in code, but when I test it on different devices the button doesn't resize and reposition itself correctly, however when I add the same button on a Storyboard it behaves properly... The storyboard does not have Autolayout enabled... EDIT3: Added photo of UI below, the larger...

Delaying IBAction Button

ios,objective-c,cocoa-touch,uibutton,uikit
I want to delay this button for 23 hours, which is 82800 seconds. It should work fine, the button does delay after one click, however when I switch to another view controller, or re-enter the application, the button delay function fails to work as it just pops back to clickable...

Checking UIButton Image

ios,objective-c,uibutton
I am trying to check some UIButton images to see if they are certain images. If they are, I want to set an NSString to a value but the value is always null. What am I doing wrong? if ([self.firstButton.currentImage isEqual:[UIImage imageNamed:@"image"]] && [self.secondButton.currentImage isEqual:[UIImage imageNamed:@"another_image"]] && [self.thirdButton.currentImage isEqual:[UIImage imageNamed:@"another_image"]]...

How to set same title color of UIButton for different states?

ios,objective-c,cocoa-touch,uibutton,uicolor
I have created an instance of UIButton and want to set the title color for Normal state, Selected state and Highlighted state. And I am doing so as- [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; [button setTitleColor:[UIColor redColor] forState: UIControlStateSelected]; [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted]; with above code when I build and run the...

Swift: Set UIButton Image with CGRect

ios,swift,uibutton,cgrect,uigraphicscontext
I'd like to set the image of a UIButton, but without creating all of the assets at different sizes. Since it should be just a grey rectangle, with some text on top, I'm trying to do this by creating a CGRect. The title is displayed as desired, and the button...

Get table cell data into UI button action?

objective-c,uitableview,uibutton,custom-cell
I want to create registration page or login page through tableView. I created a custom dynamic cell, and passed the value through array and then I created button outside the tableView. I want to get the data in button action; e.g., if the user forgot to fill one field then,...

How to show the the title under the UIButton?

ios,objective-c,uibutton,uiimage
I have used the title inset to display the text name under theUIButton. Here's my code and the output : [button setTitleEdgeInsets:UIEdgeInsetsMake(60, 0, 0, 0)]; Here's my expected output : I have used theUIButton and set the title and UIImage as background. So how to show the title label under...

UIButton height unintentionally increased - Widget - iOS 8

ios,uiview,uibutton,height,ios8-today-widget
I am developing an iOS 8 app with a Notification center widget. One problem I am having is that when I first open the widget, the UIButtons (which are in one UIView) are stretched vertically (even though I did not specify this). When the user closes notification center or swipes...

UIButton causes (lldb) error with EXC_BAD_ACCESS

ios,swift,uibutton,uikit
I've seen this issue many times on SO, but the solutions to those questions have not fixed my issue. I dynamically create a UIButton and add it to my view. I add a target to the button, which is a function. The target functions runs (i.e. the print statement runs),...

Label on UIButton not laid out correctly with autolayout

ios8,uibutton,autolayout,uikit,uistoryboard
I have an app which I'm updating to auto layout and size classes and I'm getting some weird behaviour with the label on a button. The button should be a circle and have a label in the centre. I'm implementing my own subclass so I can reuse it. Here's the...

How to set underline text of UIButton (which has custom localisation in Xcode 6.3)?

objective-c,xcode,uibutton
I know that this question is asked many times, but the most answers are several years ago. I hope there there is a easiest solution for Xcode 6.3. I have UIViewController in which I have 2 buttons which must be underlined. I also use custom solution for translating resources (my...

UIButton Text Only Appearing On Touch

ios,swift,uibutton
I've set up a UIButton as follows: let scanButton = UIButton() func setUpScanButton (scanButton: UIButton) -> () { scanButton.addTarget(self, action: "goToScanner" , forControlEvents: UIControlEvents.TouchUpInside) scanButton.backgroundColor = UIColor.greenColor() scanButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal) scanButton.setTitle("Scan", forState: UIControlState.Normal) scanButton.frame = CGRectMake(36, 385, self.view.frame.width - 41, 30) scanButton.center.x = CGRectGetMidX(self.view.bounds)...

iOS: How to handle multiple buttons created dynamically with one iBAction?

ios,uibutton,xcode6,ibaction
I have created radio and check box buttons programmatically according to my web service response, where number of buttons varies. Following is the code to create those buttons: for(int j = 0; j < nintOptionCount; j++) { UILabel * lblOption = [[UILabel alloc] initWithFrame: CGRectMake(50, yLabel, 250, 21)]; //lblOption.backgroundColor =...

UIButton doesn't appear on iOS Today Widget

ios,objective-c,uitableview,uibutton,widget
I am creating a today extension for my app, but there are some errors that I can't quite understand: First: Everything is Ok on the storyboard, but the button doesn't appear on the widget. Second: When the tableview has more than one cell, the last cell gets cut. Third: CellForRow...

My button not appears to correct position when viewController is refreshed

ios,objective-c,iphone,uibutton,programmatically-created
I am creating a simple UIButton programmatically with this frame size UIButton *pickmeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 100, self.view.bounds.size.width, 60)]; it display at perfect place where i want But on some action i want to reload the whole view controller, when i do it display the button at...

Recognizing when the UITableViewCell delete button is shown

uitableview,delete,uibutton
I have the following problem: My UITableViewCell contains an UIButton and if the user swipes from right to left to show the deletion button the button in the Cell gets triggered sometimes. Is there a way to recognize the swipe or that the deletion button is shown, so i could...

Button press functionality won't work/ Button won't press Objective C

ios,objective-c,button,uibutton
So im not necessarily sure what my exact problem is. But by reading up on some questions asked here & I think I've been able to narrow my issue down to a couple of problems. Either I have too many layers over the button itself, or I've personally screwed up...

How to shrink a rectangular round cornered UIButton to a circular UIButton?

objective-c,iphone,uibutton,core-animation
With the help of this i was able to shrink the UIButton but atlast i want the UIButton to get rounded.Please help me to get the desired animation in sign up button. The code snippet is : Follow the link : https://www.dropbox.com/s/rh4tdub3zabxp2j/shot.gif?dl=0 self.buttonShrink = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; self.buttonShrink.duration = .2f; self.buttonShrink.values...

Cannot change textColor and font size inside the loop in swift

ios,swift,uibutton,for-in-loop
I have no idea why the font size and text Color doesn't takes any effect in the loop...anyone help?? Here is my code: var buttons = ["N","F","S","D","C","A","R"] for button in buttons { var Button:UIButton = UIButton() Button = UIButton(frame: CGRect(x:10, y: 20, width: 80, height: 80)) Button.frame.origin = ButtonPosition ButtonPosition.x...

How can I create this Switch behavior?

ios,uibutton,uistoryboard,uiswitch
I want to create the following selection button to pick from the two options "Salary" and "Hourly Wage". I have images for when either (left or right) option are selected. What UI element in iOS can I use to create this? Looked into a Switch but did not see an...

Using tags in Swift

ios,swift,uibutton,tags
I have about 15 UIButtons in my controller. Im trying to clear 10 of them with a simple for loop and looks like I am getting some kind of conflict. When I hit the button to clear, I get the following error: Could not cast value of type '_UISizeTrackingView' (0x18a023c)...

How to access the content of a custom cell in swift using button tag?

uitableview,swift,uibutton,tags,tableviewcell
I have an app that has a custom button in a custom cell. If you select the cell it segues to the a detail view, which is perfect. If I select a button in a cell, the code below prints the cell index into the console. I need to access...

how to call method in controller from a UIButton in a UITableViewCell

ios,uitableview,swift,uibutton
I have a UITableView with my own UITableViewCells, which contains a UIButton. The UITableView is added to my ViewController at runtime. Everything works fine that way that I see the Button in the Cells. When pressing the Button my action is called in my UITableViewCell. Now. How can I call...

UIButtons not working in Scroll View

ios,objective-c,uibutton,scrollview
I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the...

Calling prepareforSegue from a UIButton?

ios,swift,uitableview,uibutton,segue
I am trying to call a prepareForSegue function out of TableViewController from a button in an UITableViewCell. Can I just call it from the button? Something like: TableViewcontroller: func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { if (segue.identifier == "segueExercise") { print(segue.identifier) let vc = segue.destinationViewController as! DetailViewController TableViewCell: @IBAction func exerciseAction(sender:...

Swift - UIButton with two lines of text

ios,swift,uibutton
I was wondering if it is possible to create a UIButton with two lines of text. I need each line to have a different font size. The first line will be 17 point and the second will be 11 point. I've tried messing with putting two labels inside of a...

Set UIButton Image in Swift - currently unwraps as nil

ios,swift,uibutton,uiimage,optional-values
I am having a difficult time setting an image of a UIButton. I have checked other posts on how to do this, and it seems straightforward enough (but then, here I am). In my program, the image that the button displays depends on trip.weather. I am using a switch to...

how can I create a button with texturepackerimporter texture?

unity3d,uibutton,texturepacker
I can drag the prefabs texture to scene. But I don't know how to create a ui button use this texture.

How do you pass the object selected in tableView:didSelectRowAtIndexPath to new UIViewControllers pushed onto the stack?

ios,objective-c,uitableview,uibutton
I'm displaying a list of items in a tableViewController, then when a row is selected pushing a viewController with a .xib file onto the stack, giving a more detailed explanation of the item in a textView with a few UIButtons to select for further action. All of this works so...

Changing titles on buttons with custom NSString

ios,objective-c,uibutton
I need to change the title of a button, but the title of the button needs to change depending on the index of the NSArray I choose. How do I do that? Code: NSArray * answerChoiceArray1 = @[@"1492", @"13", @"Spain", @"1678", @"1775", @"1848", @"1899", @"1908", @"1928", @"1999", @"12,000s BCE", @"Caral",...

UIButton with multi-line titleLabel with NSAttributedString doesn't work in iOS 7 but works in iOS8

ios7,uibutton,nsattributedstring
In my project i have a requirement to show a UIButton that has two lines of text in its titleLabel With NSAttributedString. Its working fine in iOS8 but Where as in iOS7 its not working,i can see two lined text after selected button. This is the code I'm using: calendarBtn=...

How to set image and text in front of gradientLayer on UIButton?

ios,swift,uibutton,layer
My code looks like this: pickerCountry = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton pickerCountry.frame = CGRectMake(self.view.frame.size.width/2 - pickerCountry.frame.size.width, 50, 100, 100) pickerCountry.center.x = self.view.center.x pickerCountry.setTitle("Start1", forState: UIControlState.Normal) pickerCountry.setImage(UIImage(named: "Britain_mdpi.png"), forState: UIControlState.Normal) pickerCountry.tintColor = UIColor.blackColor() pickerCountry.titleLabel?.tintColor = UIColor.blackColor()...

How to draw a triangle shaped UIButton

ios,uibutton,core-graphics,cgcontext
I really dig the IFTTT bottom right corner button, as shown in the image (bottom right). I tried playing around with CGContext and UIBezierPath to match the effect, but i simply don't know enough to get this right. Does anyone have some thoughts/code on how to make this happen? Thanks!...

sharing problems in ipad

ios,objective-c,uibutton,unrecognized-selector
I have a problem when I try to use a shared sharing in social networks but I get an error error: as follows 2015-05-20 14:01:05.267 NovedadesQuintanaRoo[945:174927] Sharing2 2015-05-20 14:01:05.733 NovedadesQuintanaRoo[945:174927] -[UIButton view]: unrecognized selector sent to instance 0x7fb468d8bac0 2015-05-20 14:01:05.741 NovedadesQuintanaRoo[945:174927] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:...

UIButton won't generate randomly when score is added?

ios,objective-c,xcode,uibutton
I am having a problem with my coding on Xcode. I am making an app in which a target appears, then you have to tap it, but the time allowed between each tap shortens gradually. MY PROBLEM: whenever I try and make a UILabel update after a tap, the target...

UIButton with pushViewController that is declared in another class

ios,objective-c,uiviewcontroller,uibutton
Hi everyone I am trying to add a custom nav bar that is declared in a different class and has a button that make a push action. My initial problem was that when the app was pushing the view because of the uinavicgationconreoller it was crashing, I fixed that somehow...

Set bool for UIButton Class in View controller (Swift)

ios,swift,uibutton
I have a Custom Class for my UIButton. In this class I have the code below to draw the button. I would like the user to tap a button and toggle one part hidden/ not hidden. I don't know how to set the Bool value for this. Thanks import UIKit...

UISwipeGestureRecognizer over UIButtons

ios,cocoa-touch,uibutton,uikit,uigesturerecognizer
I want swipes to be detected on the lower half of the screen. That part of the screen can have UIButtons as well. I want the swipes to take priority over the buttons (that is, if you swipe over the buttons, the buttons are ignored). But I want the buttons...

Draw attention to and foster discovery of actionable controls

ios,ios8,uibutton
In an attempt to defer to content, I chose not to use any (navigation or tool) bars. The app has a tinted UIButton which brings up an action sheet (where the user could share the content, and adjust preferences). What I've seen is that people don't interact with the button....

How to get button title from dynamically generated buttons in Objective C?

ios,objective-c,uibutton
I have already dynamically created a row of buttons in my controller implementation class and added them to the view. The title of each button is set to a corresponding number; the first button has a title of "1", the second is "2", and so forth. I would like to...

Objective C: Adding UI button with constraints programatically

ios,objective-c,uibutton,autolayout
I want to create button of fixed dimension which is set to fix distance from top right regardless of screen size and orientation, But not able to achieve it. I have tried following code which shows correctly in portrait mode only since frame location is fixed. self.closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];...

How to change image of UIImageView that is inside a UIButton programatically?

ios,objective-c,iphone,uiimageview,uibutton
I created a UIButton with UIImageView and UILabel by the help of this question and answer by Tim and now I want change the image of the UIImageView on the button click event. I tried [sender.imageView setImage:image] but it not working

Increase a Progress bar value on a UIButton press in Swift

ios,swift,uibutton,uiprogressbar
Okay let me give you an overview of what happens so far. I have three questions in an array. Every time the 'Next' button is pressed, it will slide to the next question in the array. What I would like to happen, is when the next question in the array...

IBAction Button Press (Don't want to see the press)

ios,uibutton,ibaction
So I have a few buttons in an application and obviously they can all be pressed and do various things... My question is, how can you "not display" the colour change or visual aid that happens on screen once a button is pressed? To be honest, I'm not sure how...

Why not changed uibutton title programatically in swift?

ios,swift,uibutton
I have a UIButton on the screen and i would like to change this title at start. i tried this: @IBOutlet weak var addCardCenterBtn: UIButton! func roundedButton(){ self.addCardCenterBtn = UIButton.buttonWithType(.Custom) as! UIButton self.addCardCenterBtn.layer.cornerRadius = 0.5 * addCardCenterBtn.bounds.size.width self.addCardCenterBtn.backgroundColor = UIColor.blackColor() self.addCardCenterBtn.setTitle("AS", forState: UIControlState.Normal) } override public func viewDidAppear(animated: Bool) {...

How can i set Frame properly After dragging?

ios,uibutton,uipangesturerecognizer,cgrect,cgpoint
I am Building iOS App Using StoryBoards. In My App, I want to create a custom slider. For that I created two views and image programmatically. Big View is considered as slider. And small one means the thumb.I applied panGesture for the thumb so that it can be moveable. It...

UIButton in custom cell not working

ios,swift,uibutton,custom-cell
I have a button in a custom cell class CardTableViewCell: UITableViewCell { @IBOutlet weak var detailsButton: UIButton! } in my view controller then I do this func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //.....more code.... openDealCell.detailsButton.addTarget(self, action: "push:", forControlEvents: UIControlEvents.TouchUpInside) } and then: func push(sender:AnyObject) { println("tap") }...

How do I ensure that the text entered into a UIAlertview transforms the text of a UIButton and STAYS that way after exiting and reentering the app

ios,objective-c,uibutton,constraints,nsuserdefaults
TL;DR : Open iOS app Enter a promo code Close app Open app Actual Results: Promo code box is out of wack (see images) Expected Results: Promo code should still be displayed So I've got a UIButton whose text keeps changing after the user clicks on it and exits and...

Shadow on UIButton text only (not background)

ios,objective-c,cocoa-touch,uibutton,shadow
I have a set of UIButtons with background colors. when the user taps one, I want only the button's text to have a shadow all around it (to show that it has been selected). However, when I add the shadow, the shadow appears over the whole button (background and all),...

Swift: Animating UIButton after auto-formatting UITextField

ios,swift,uibutton,switch-statement,uitextfield
I have a UITextField that only takes numbers. It's a phone number field. Once there are 10 characters in the field (area code + number), I convert the textField.text string to an NSMutableString to format it to a phone number. Now, once the format takes place, I need to animate...

How to ignore all UIControl Taps, when using the tap to close UIKeyboard

ios,swift,uibutton,uikeyboard
This issue is stemming from my previous question dismiss keyboard on tapping on any UIControl object. So when user has a keyboard present, I want the user to be able to tap anywhere outside of keyboard or UITextView to close keyboard. This works...But I also want that "first" tap that...

Unwanted Invisible detection area around UIButton when Highlighted

ios,iphone,xcode,swift,uibutton
I am creating a "yes" and "no" UIButton in a universal device app in my viewDidLoad, like so: let yesUnpressedTexture = UIImage(contentsOfFile:NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("yesButtonUnpressed.png"))! let yesPressedTexture = UIImage(contentsOfFile:NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("yesButtonPressed.png"))! let buttonWidth = yesUnpressedTexture.size.width var yesButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton...