Menu
  • HOME
  • TAGS

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

uitableview,swift,uibutton,tags,tableviewcell

OPTION 1. Handling it with delegation The right way of handling events fired from your cell's subviews is to use delegation. So you can follow the steps: 1. Above your class definition write a protocol with a single instance method inside your custom cell: protocol CustomCellDelegate { func cellButtonTapped(cell: CustomCell)...

UIButton text not staying changing

ios,uitableview,swift,uibutton

Use UIButtons's setTitle: forState: rather than setting text on titleLabel of button. For Instance- Initial set up likeButton.setTitle("Hello World", forState: UIControlState.Normal) On click set up- @IBAction func buttonAction(sender: AnyObject) { if likeButton.titleLabel?.text == "Hello World" { likeButton.setTitle("Hi!", forState: UIControlState.Normal) } } ...

Update button image on swift 2.0

ios,uibutton,swift2,xcode7

The forState argument cannot be nil - It has to be a UIControlState. In your case, you should use UIControlState.Normal if counter % 2 == 0{ playButton.setImage(UIImage(named: "pause"), forState: UIControlState.Normal) } else if counter % 2 == 1 { playButton.setImage(UIImage(named: "play"), forState: UIControlState.Normal) } ...

How can I create this Switch behavior?

ios,uibutton,uistoryboard,uiswitch

The control you are looking for is a UISegmentedControl - see the Apple Docs.

UIButton not Blinking on Touch

ios,objective-c,uibutton

The problem is that your custom color for the normal state applies also for the highlighted state, unless you give it a separate color for the highlighted state. This is true of all button state related values.

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

ios,swift,uibutton,layer

You mention you've set your UIButton's title color but I don't see where you're setting your UIButton's title color. Use: pickerCountry.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal) ...

Calling prepareforSegue from a UIButton?

ios,swift,uitableview,uibutton,segue

Solved. I passed the index via UIButton option tag and replaced the indexPathForSelectedRow.

UISwipeGestureRecognizer over UIButtons

ios,cocoa-touch,uibutton,uikit,uigesturerecognizer

You may try adding the UISwipeGestureRecognizer to the superview of the UIButton.

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

ios,uibutton,ibaction

Try using yourUIButton.adjustsImageWhenHighlighted = NO; ...

how can I create a button with texturepackerimporter texture?

unity3d,uibutton,texturepacker

You don't need TexturePacker to create a button. Unity has a SpritePacker that handles all the texture packing. To create a button select GameObject > UI > Button and in the Inspector View drag in your texture. And take a look at this Introduction Tutorial from Unity: http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button...

UIButton Text Only Appearing On Touch

ios,swift,uibutton

Your button is most probably drawn on a secondary thread. So it won't be drawn at the right time. To be correctly drawn and at the right time, all UI elements have to be drawn on the main thread. You can achieve that with the following code: dispatch_async(dispatch_get_main_queue(), { //...

UIButton not showing highlight on tap in iOS7 - Swift

ios,swift,uibutton,highlight

Thanks to Schemetrical, this is the working version for me. (iOS 7 + 8) First I wrote a utility function: class func classNameAsString(obj: AnyObject) -> String { return _stdlib_getDemangledTypeName(obj).componentsSeparatedByString(".").last! } then I subclass UITableView and implement this: required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) for view in self.subviews { if...

Shadow on UIButton text only (not background)

ios,objective-c,cocoa-touch,uibutton,shadow

Just set the shadow on the titleLabel property of the UIButton rather than what you're doing now. eg button.titleLabel.shadowColor = ((selectionState) ?[UIColor orangeColor] : [UIColor clearColor] ); button.titleLabel.shadowOffset = CGSizeMake (1.5,1.5); ...

Get table cell data into UI button action?

objective-c,uitableview,uibutton,custom-cell

You can create custom cells or can manage UITableviewCell by tags. On Your button tap event, get Tableviewcells one by one and validate the textbox values with in cell. To identify cells You can check class of cell and tag for that cell. Remember in cellForRowAtIndexPath you must assign tag...

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

ios,objective-c,uitableview,uibutton

Don't you want this? JASIdea *selectedIdea = self.idea; If I understand your code correctly, you're going from an edit button on JASDetailViewController to JASEditViewController, but the JASIdea instance is staying the same. You passed selectedIdea from your table view's didSelectRowAtIndexPath into JASDetailViewController.idea. That means that it's there in self.idea when...

iOS UIButton click doesn't work

ios,objective-c,iphone,uiview,uibutton

I think the problem is with self.header. You need to set frame to it. self.header.frame = CGRectMake(0, 0, 320, 80); After this that your button should start registering touch. WHY? Good Question. As you self.header's layer have property maskToBounds which by default set to no, so any view that you...

Draw attention to and foster discovery of actionable controls

ios,ios8,uibutton

Let it glow. Let it glow. Let it glow. view.layer.shadowColor = [UIColor whiteColor].CGColor; view.layer.shadowRadius = 10.0f; view.layer.shadowOpacity = 1.0f; view.layer.shadowOffset = CGSizeZero; [UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction animations:^{ [UIView setAnimationRepeatCount:5]; view.transform = CGAffineTransformMakeScale(1.2f, 1.2f); } completion:^(BOOL finished) {...

why is my app stalling when the play button is tapped

ios,swift,uiviewcontroller,uibutton,xcode6

You can profile the application to see which part of the code is taking a long time to execute, that will help you narrow it down. Hold down on the run button and select profile. Tap on "Time Profiler" from the menu that comes up. Tap on the record button...

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

ios,swift,uibutton,text-alignment

Here is whole as you want. import UIKit class ViewController: UIViewController { @IBOutlet var button: UIButton! override func viewDidLoad() { super.viewDidLoad() var str : NSMutableAttributedString = NSMutableAttributedString(string: "From station\nSTN\nStation Name") str.addAttribute(NSFontAttributeName, value: UIFont.systemFontOfSize(20), range: NSRange(location: 13,length: 3)) button.setAttributedTitle(str, forState: UIControlState.Normal) button.titleLabel!.lineBreakMode = .ByWordWrapping button.titleLabel?.textAlignment = .Center...

Change color of the UIButton title navigation bar

swift,ios8,uibutton,navigationbar

You can try this steps : in the main.storyboard, for each view, you can change in the simulated metrics section the value of top bar to translucent navigation bar add in the navigation item created your buttons link the buttons from main.storyboard to your file and change the color with...

How to customize uibutton's class in Swift?

ios,swift,uibutton,subclassing

The best way is that you make a generic button class for all your different colored buttons. After you init the new button, you can set the color. Another way is to use a designated initialiser with a UIColor so that your code adapts to the color you feed to...

Changing titles on buttons with custom NSString

ios,objective-c,uibutton

Simply use variable name (if it is a string) //if it is a string [_displayAnswerChoice1 setTitle : currentQuestion.answerChoice1 forState : UIControlStateNormal]; //If you want to add prefix, suffix or any other formatted text then use stringWithFormat [_displayAnswerChoice1 setTitle : [NSString stringWithFormat : @"%@", currentQuestion.answerChoice1] forState : UIControlStateNormal]; ...

UIButton – what is the default image highlight color

ios,uibutton,uibarbuttonitem,back-button,uicolor

You need to merge two kinds of UIColor together, First,you can get the tintColor use : UIColor *defualtTintColor = self.navigationController.navigationItem.backBarButtonItem.tintColor; merge redColor and the defualtTintColor together. That is my method,Inelegant, but it works: UIColor* blend( UIColor* c1, UIColor* c2, float alpha ) { alpha = MIN( 1.f, MAX( 0.f, alpha...

Why not changed uibutton title programatically in swift?

ios,swift,uibutton

Remove this line self.addCardCenterBtn = UIButton.buttonWithType(.Custom) as! UIButton. Because it is already initialised. When you connect any control from storyboard to ViewController, never initialise it again. Just make the changes to it and the new changes will take effect....

How to show the the title under the UIButton?

ios,objective-c,uibutton,uiimage

Please Select button in xib first. then select Attribute Inspector, in this Select Title in "Edge" and set appropriate "Inset" as per Requirements. please take a look with below code and set insets as per your Requirements. UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.frame = CGRectMake(0, 0, self.view.bounds.size.width, 40); [myButton setImage:[UIImage...

iOS: Button backgroundImage not changing in Annotation Callout View

ios,uibutton,mkmapview,calloutview

First set 2 different images for two states of button. [btn setBackgroundImage:img1 forState:UIControlStateNormal]; [btn setBackgroundImage:img2 forState:UIControlStateSelected]; then on buttonPress event set button.selected = !button.selected ...

Strange behavior when adding UIButton to UICollectionViewCell

ios,objective-c,uiimageview,uibutton,uicollectionviewcell

Add this code in your button action CGPoint ButtonPoint = [sender convertPoint:CGPointZero toView:self.collectionView]; NSIndexPath *ButtonIndex = [self.collectionView indexPathForItemAtPoint:ButtonPoint]; buttonindexpath = ButtonIndex.row [collectionView reloadData]; Now in your cellForItemAtIndexPath, check if indexPath.row == buttonindexpath, if yes give the code you gave in button action.... ie.... if (indexPath.row == buttonindexpath) { if ([self.favoriteChecked...

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

ios,objective-c,button,uibutton

You need to set userInteractionEnabled to NO on your subviews as this property on UIViews defaults to YES. This will allow the touches to pass through the views to your UIButton.

UIButton in custom cell not working

ios,swift,uibutton,custom-cell

Fix it! The problem was not in the code but in my cell in the storyboard: where user interaction for the cell wasn't enabled and all the other view didn't allow the user interaction. ...

UIButton creating error - “unrecognized selector sent to instance”

swift,uibutton

You should modify addTarget: button.addTarget(self, action:Selector("buttonAction:"), forControlEvents: UIControlEvents.TouchUpInside) ...

UIButtons not working in Scroll View

ios,objective-c,uibutton,scrollview

First make the button to custom type Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state. Now you can see the colour change on that button. ...

Delaying IBAction Button

ios,objective-c,cocoa-touch,uibutton,uikit

You should use NSUserDefaults. When save: method is called check current date [NSDate date] and save it into the user defaults. Then (when time has already passed) you retrieve the saved date from the defaults and compare it to the current date. If 23 hours have already passed you enable...

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

ios,objective-c,timer,uibutton,uilabel

You want to use a button to present count down? I think you can use the way below. I tried it and it works for me. I have three properties @property(nonatomic,assign)NSInteger time; @property (weak, nonatomic) IBOutlet UIButton *smsButton; @property(nonatomic,strong)NSTimer *timer; And then start the timer with a method: - (void)smsButtonPressed...

UIButton doesn't appear on iOS Today Widget

ios,objective-c,uitableview,uibutton,widget

1)For your second problem, your cellIdentifier in tableView:cellForRowAtIndexPath will be "static" like this : static NSString *cellName = @"WidgetCell"; WidgetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName forIndexPath:indexPath]; 2)this condition will be never execute because it's never nil : if (cell == nil) { cell.nomeTimer.text = [listaFavoritos objectAtIndex:indexPath.row]; } replace it by this...

Change text color of UIButton in CalloutAccessoryView

ios,swift,uibutton

You can change the title/text color of a UIButton like so: button.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal) ...

UIButton with pushViewController that is declared in another class

ios,objective-c,uiviewcontroller,uibutton

Probably the addTopBarToScreen is in another class, that is unrelated to the HomeViewController and doesn't have the productSheetsButtonFunction defined. You can do this in several ways, but the simplest one, reusing your structure, is to pass the target in the addTopBarToScreen method, like this: - (void)addTopBarToScreen:(UIView *)screen target:(id)target Then, in...

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

ios,uitableview,swift,uibutton

Just don't add target from UITableViewCell class instead add it in cellForRowAtIndexPath method override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cellIdentifier", forIndexPath: indexPath) as! SomeCustomCell cell.button_in_cell.addTarget(self, action: "viewControllerMethod:", forControlEvents: UIControlEvents.TouchUpInside) } ...

Label on UIButton not laid out correctly with autolayout

ios8,uibutton,autolayout,uikit,uistoryboard

Ok, this was a real school boy error. When the docs said 'The implementation of this method is empty before iOS 6' I for some reason took this to mean there's no need to call super on layoutSubviews. So the fix was: -(void) layoutSubviews { [super layoutSubviews]; // <<<<< THIS...

Checking UIButton Image

ios,objective-c,uibutton

You can do like this [[self.firstButton imageForState:UIControlStateNormal]isEqual:[UIImage imageNamed:@"image"]] Try this one. This may help....

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

ios,objective-c,xcode,uibutton,mkmapview

Since iOS8 you have to set a usage description for location services: http://stackoverflow.com/a/24718342/4948826

Swift - update UIButton image from last photo in roll

swift,uibutton,camera-roll

Try this, I am not sure you need to fetch the last photo. Just update the UIButton background image like so. Should give the effect you are after. Let me know if it fixed it. if let capturedImage = image? { println("capture image") //animate button effect UIView.animateWithDuration(0.3, animations: { sender.backgroundColor...

Removing image from button misplaces text

ios,objective-c,uibutton

If you have both text and image on a UIButton they are adjusted so both of them ar visible, if you are just removing the text by default it should show in the center of button if you remove the image. It should not move it to bottom left, can...

UIButton won't generate randomly when score is added?

ios,objective-c,xcode,uibutton

print targX = arc4random() %769; targY = arc4random() % 925; in both methods , check whether you are getting proper points. And check generated points lies with in device screen....

Using tags in Swift

ios,swift,uibutton,tags

As there was already said by @ranunez, the default tag is 0. I don't agree with the advice to use non-zero tags. My advice is, don't use tags at all. If you want to use a view in code, declare an outlet for it and connect it. If you want...

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

ios,swift,uibutton,uikeyboard

But I also want that "first" tap that closes the keyboard to not cause any other actions. You can do it the way you are doing it, but that's very inflexible because you have to deal with all those other controls separately and individually. The simplest way to do...

Multiple Buttons, But only one pressed at a time

ios,objective-c,uibutton

In collection view datasource method - collectionView:cellForItemAtIndexPath: when you are configuring the cell, set the indexPath item value as tag of the corresponding button in the cell. Then maintain a property say, previousSelectedButtonIndex in which you can maintain the value of the previously selected index. In your button click handler,...

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

What ended up being the actual problem was the fact that I wasn't using UIControlStateSelected. A foolish error. But that was the actual issue. Even after synchronizing my defaults and making sure the success block was returning the data properly, and that I was then accessing that data properly, the...

Change UIButton type in subclass if button created from storyboard

ios,swift,uibutton

I think it is not possible at runtime. Since it is a read-only method. I think you will get helpful questions from these links. set UIButton's buttonType programmatically Change UIButton type programatically how to set UIButton type in UIButton Subclass...

Set bool for UIButton Class in View controller (Swift)

ios,swift,uibutton

I managed to achieve this by using the code below. I have a UIButton class with this: override func drawRect(rect: CGRect) { // Drawing code //// Rectangle Drawing let rectanglePath = UIBezierPath(roundedRect: CGRectMake(3, 3, 34, 34), cornerRadius: 10) UIColor.darkGrayColor().setStroke() rectanglePath.lineWidth = 3 rectanglePath.stroke() if (darwCheck == true) { //// Bezier...

Custom UIButton Swift 2.0

ios,swift,uibutton,ios9

Did you try this? var myButton = MyCustomButton(type: .Custom) ...

UIButton Multiple Labels Using UIControlStates

ios,objective-c,uibutton,uicontrolstate

Subclass UIButton and add your additional labels in there as instance variables. Then override -setHighlighted and -setSelected to adjust the additional labels as desired. FYI - you call [myButton setTitleColor...], not [myButton.titleLabel setTitleColor...]

How to draw a triangle shaped UIButton

ios,uibutton,core-graphics,cgcontext

First use a CAShapeLayer to create a mask CAShapeLayer * shapeLayer = [CAShapeLayer layer]; //Use these to create path CGMutablePathRef path = CGPathCreateMutable(); // CGPathMoveToPoint // CGPathAddLines shapeLayer.path = path; Then set mask of your button yourbutton.layer.mask = shapeLayer yourbutton.masksToBounds = YES; Example of a view CAShapeLayer * shapeLayer =...

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

ios,objective-c,uibutton

The correct way to do this is by using the next line of code: UIButton *aButtonReconstruct = (UIButton *)[self.view viewWithTag:aTag]; where aTag is an int and is greater than 0, because all the views have the tag 0 by default, so in the for loop used in the first place,...

Swift - How to properly architect buttons in MVC?

ios,swift,uiview,uibutton,segue

button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) button.addTarget(self, action: "saveButton:", forControlEvents: UIControlEvents.TouchDown) The normal thing is that the button should be sending messages to its view controller. That is the standard MVC thing to do - indeed, that is the VC in MVC (the View is letting the Controller know there has...

Issue with using RGB colors in IOS

objective-c,ios7,uibutton,xcode6,uicolor

try to use this code self.layer.backgroundColor = [UIColor colorWithRed:60/255.0f green:146/255.0f blue:180/255.0f alpha:1.0f].CGColor; You need to convert UIColor to CGColor which can be done by above code. Hope this will solve your problem...

UIButton causes (lldb) error with EXC_BAD_ACCESS

ios,swift,uibutton,uikit

Edit: It looks like init is a special keyword Swift uses when bridging ObjC code. From the docs: Initialization To instantiate an Objective-C class in Swift, you call one of its initializers with Swift syntax. When Objective-C init methods come over to Swift, they take on native Swift initializer syntax....

Getting An Item from IBOutletCollection in Swift

ios,swift,uibutton,iboutletcollection

@IBOutlet var customerDashboardButtons:[NSArray]? Creates an array of arrays. Calling customerDashboardButtons!.first will return the first array (the NSArray) in your array (the […] will also create an array) I suspect you want your customerDashboardButtons to be an array of UIButton’s so you would use @IBOutlet var customerDashboardButtons:[UIButton]? Using customerDashboardButtons!.first here will...

How can i set Frame properly After dragging?

ios,uibutton,uipangesturerecognizer,cgrect,cgpoint

You are mixing between setting the frame origin and the frame centre. As you pan with the gesture you're setting thumbXCord = (int)thumb.center.x; so you're creating an offset of half the width of the thumb. Either be consistent about what you're setting or update the thumbXCord to account for the...

UIButton with single press and long press events swift

ios,iphone,swift,uibutton

If you want to perform any action with single tap you and long press the you can add gestures into button this way: @IBOutlet weak var btn: UIButton! override func viewDidLoad() { let tapGesture = UITapGestureRecognizer(target: self, action: "Tap") //Tap function will call when user tap on button let longGesture...

How to increase height of UIButton image without moving button

swift,uiview,uibutton

You should be able to get the effect you're after using transforms. I would do the following: Start with the identity transform. Shift the origin of the transform down to the bottom of the image. Increase the transform's scale.y as desired. Shift the transform's origin back to the center of...

Create a rating view in IOS objective c

ios,objective-c,uibutton,rating

Step 1) Add 5 UIButton to your UI file. Then in your header (.h) code, declare the UIButton like so: IBOutlet UIButton *starOne; IBOutlet UIButton *starTwo; IBOutlet UIButton *starThree; IBOutlet UIButton *starFour; IBOutlet UIButton *starFive; Then back in your UI file, link the star button views to your code. Then...

Swift: Set UIButton Image with CGRect

ios,swift,uibutton,cgrect,uigraphicscontext

Try this code : var yourbutton = UIButton(frame:CGRectMake(100, 100, 100, 35)) var rect = CGRectMake(0, 0, 1, 1) UIGraphicsBeginImageContext(rect.size) var context : CGContextRef = UIGraphicsGetCurrentContext() CGContextSetFillColorWithColor(context, UIColor.blackColor().CGColor) CGContextFillRect(context, rect) var image : UIImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() yourbutton.setBackgroundImage(image, forState: UIControlState.Normal) self.view.addSubview(yourbutton) ...

How to dynamically add an action to a UIButton

ios,swift,uibutton

Your method should be func configureButton (button: UIButton, action: Selector, title: String, pos: [CGFloat]) Note how it uses Selector instead of String. This is because Swift has no built in implementation of a Selector, you pass a string and the string literal is type inferred into a Selector (just like...

Prevent iOS from darkening image of pressed button

ios,uibutton

This is controlled by UIButton.adjustsImageWhenHighlighted. You can set this to false either in code or in your nib/storyboard file.

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

c#,user-interface,unity3d,uibutton,unityscript

At a guess, your Canvas' CanvasScaler's UI Scale Mode is probably set to Constant Pixel Size, and if your mobile device's resolution is too high, text will appear small. Try changing the UI Scale Mode to Scale With Screen Size and change the properties it provides as needed. (if your...

How to make a double line border UIButton?

ios,swift,uibutton,border

Another alternative would be to create a stretchable image using the UIImage method resizableImageWithCapInsets. What you do is to create an image that has the inside collapsed down to it's smallest possible size (1 pixel in this example) and then specify the sizes of the edges. When you create a...

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

objective-c,iphone,uibutton,core-animation

I did some tinkering and got pretty decent results. EDIT: I just uploaded a demo project to GitHub called MorphingButton (link) that generates the animation below: Here's what I did: I created a normal iOS 8 button in IB (no outline at all) and connected an outlet and an action...

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

ios,objective-c,uitableview,model-view-controller,uibutton

The second option will certainly violate MVC pattern. ViewController works like a glue between your models, views and contains all the business logic. ViewController should receive action then make your api call and put formatted data to your views. Usually in my project I always try to move networking code...

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

ios7,uibutton,nsattributedstring

You need to use this line to set attributed title [calendarBtn setAttributedTitle: ddStr forState:UIControlStateNormal]; instead of calendarBtn.titleLabel.attributedText=ddStr; Hope it helps :)...

Set custom attribute on button

ios,swift,uibutton

If you need custom properties on a class that doesn't belong to you, subclass it and use the subclass instead. class MyCoolButton : UIButton { var myCoolProperty : String = "coolness" } And later: var btn = MyCoolButton( // ... ...

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

ios,uibutton,xcode6,ibaction

You have to declare your button inside your for loop. so each time loop run a new instance of button will generate. Create array to save buttons. NSMuttableDictionary *btnRadioDictionary = [NSMutableDictionary new]; NSMuttableDictionary *btnCheckBoxDictionary= [NSMutableDictionary new]; Set tag for each button inside loop for(int j = 0; j < nintOptionCount;...

Unwanted Invisible detection area around UIButton when Highlighted

ios,iphone,xcode,swift,uibutton

This is actually a feature of the OS and how touch events work. When you touch a UIControl (a UIButton in your case), the OS starts tracking your touch and movements and there's a predefined bounding rect around your control. Only after you move your finger outside this bound, the...

iOS UIButton title keeps reverting in UITableViewCell

ios,uitableview,uibutton,interface-builder,uistoryboard

From the apple docs of titleLabel Do not use the label object to set the text color or the shadow color. Instead, use the setTitleColor:forState: and setTitleShadowColor:forState: methods of this class to make those changes. Similarly for text you should use setTitle:forState: [sender.titleLabel setTitle:@"Clicked" forState:UIControlStateNormal]; ...

Delete a row from other UIViewController with a UIButton

ios,objective-c,uitableview,uiviewcontroller,uibutton

You can use delegates, as you want to communicate between two view controllers. Create a protocol in DetailViewController. While you initially segue from TableViewController to DetailViewController set "idx" as the selected indexPath.row or array index. When you delete it from DetailViewController, delegate will send the index to the TableViewController and...

Recognizing when the UITableViewCell delete button is shown

uitableview,delete,uibutton

Solution: I check in the buttons event whether the tableview is currently in editing mode. This solved the problem :)

Objective C: Adding UI button with constraints programatically

ios,objective-c,uibutton,autolayout

Try this code,just replace 60 to what you want self.closeBtn = [UIButton buttonWithType:UIButtonTypeCustom]; self.closeBtn.frame = CGRectMake(260, 30, 50, 28); self.closeBtn.layer.cornerRadius = 4; self.closeBtn.layer.borderWidth = 1; self.closeBtn.layer.borderColor = [UIColor colorWithRed:179.0/255.0 green:179.0/255.0 blue:179.0/255.0 alpha:1.0].CGColor; [self.closeBtn setTitleColor:[UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0] forState:UIControlStateNormal]; self.closeBtn.backgroundColor = [UIColor...

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

ios,objective-c,iphone,uiimageview,uibutton

you can: 1 - keep a reference to the UIImageView inside the UIButton on your viewController 2 - Subclass the UIButton and add the UIImageView yourself. 3 - When adding the UIImageView, add a tag into it (view.tag) and when getting the view from the sender, you can just UIView...

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

ios,arrays,swift,uibutton,segue

You should check your index against count - 1 because index is zero-based. if currentQuestionIndex < questions.count - 1 && currentPlaceholderIndex < placeholder.count - 1{ currentQuestionIndex++ currentPlaceholderIndex++ buttonLabel.setTitle("Next", forState: UIControlState.Normal) } else { performSegueWithIdentifier("countdownSegue", sender: self) } EDIT: You didn't check the index when getting values from your array to...

How to update UI with WatchKit?

ios,uibutton,uilabel,watchkit

To update a WKInterfaceLabel's text property you need to use setText(): self.myLabel.setText("new text") ...

My button not appears to correct position when viewController is refreshed

ios,objective-c,iphone,uibutton,programmatically-created

Set AutoresizingMask for button UIButton *pickmeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 60, self.view.bounds.size.width, 60)]; [pickmeButton setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin]; ...

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

ios,uibutton,uikit,uilabel

The UIButton class, as well as lots of other UIControl subclasses can have numerous actions hooked up to them. When we are hooking up an action from interface builder to our source code file, if we open the "Event" drop down, we're presented with a long list of options: In...

Set UIButton Image in Swift - currently unwraps as nil

ios,swift,uibutton,uiimage,optional-values

Try this after NSLog(" (theImage.description)") if let tempButton = self.weatherButtonImage { tempButton.setImage(theImage, forState:.Normal) } else { NSLog("Button is nil") } To determine if its your button that is nil. If your button is nil, reconnect it in storyboard....

Increase a Progress bar value on a UIButton press in Swift

ios,swift,uibutton,uiprogressbar

I'm not sure what the fix would be at this time, since I'm still learning swift at the moment, so just give you an idea. But I think it is something with the value you set, the 0.333. With the code you have right now, you are setting it to...

Cannot change textColor and font size inside the loop in swift

ios,swift,uibutton,for-in-loop

First remove the line Button.titleLabel?.text = "\(button)". This one is enough Button.setTitle("\(button)", forState: UIControlState.Normal). Then you should use setTitleColor method from a button to change it. Button.setTitleColor(UIColor. blackColor(), forState: UIControlState.Normal) Finally you made a mistake in the name of your font : Button.titleLabel?.font = UIFont(name:"ChalkboardSE-Regular", size: 30.0) That's it!...

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

objective-c,xcode,uibutton

I tried to set NSMutableAttributedString as text, but the setTitle method needs NSString and I have error. Because you are calling the wrong method. You want the setAttributedTitle:forState: method, which solves that problem. I see that I can set attributed text in Xcode 6.3, but in that case the...

sharing problems in ipad

ios,objective-c,uibutton,unrecognized-selector

You can't cast sender to UIBarButtonItem since sender is actually a UIButton. Change the line: controller.popoverPresentationController.barButtonItem = (UIBarButtonItem *)sender; to: controller.popoverPresentationController.sourceView = sender; ...

UIButton setAutoresizingMask not working programatically

ios,objective-c,uibutton

Set UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleHeight [button1 setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; When you add button in IB with AutoresizingMask it's autoresize after lunch. For example, screen width increases from 320 (in storyboard) to 540px (on device) and button size increases proportionally. When you add button programmatically it's just added and you should calculate...

UIButton not highlighted on border

ios,objective-c,uibutton,uigesturerecognizer

Finally I realised that the problem was a UIScreenEdgePanGestureRecognizer that I have. Since my button is positioned to the left of the screen, this small left part of the button was canceled by the UIScreenEdgePanGestureRecognizer. I solved this by adding the following code to my UIViewController: - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch...

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

ios,objective-c,uibutton,respondstoselector

Responds to selector doesn't just check the public interface, it'll take any method it can find. I don't recall if the early API for UIButton ever exposed the title directly, but internally it's likely called as the state changes. Try to only use respondsToSelector: for API that you actually need...

Setting layer out of layer in UIbutton?

ios,objective-c,uibutton,uiimage,calayer

This is my output code for my solution - UIButton *picBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 60, 60)]; [picBtn setImage:[UIImage imageNamed:@"CM.png"] forState:UIControlStateNormal]; [picBtn setBackgroundColor:[UIColor clearColor]]; [picBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)]; [picBtn.layer setCornerRadius:picBtn.frame.size.height/2]; [picBtn.layer setBorderWidth:2]; [picBtn.layer setBorderColor:[[UIColor grayColor] CGColor]]; ...

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

ios,objective-c,cocoa-touch,uibutton,uicolor

You need to understand how bit masks work. Merlin has pointed in the right direction, but he hasn't actually given an explanation. typedef NS_OPTIONS(NSUInteger, UIControlState) { UIControlStateNormal = 0, UIControlStateHighlighted = 1 << 0, // used when UIControl isHighlighted is set UIControlStateDisabled = 1 << 1, UIControlStateSelected = 1 <<...

Swift: Animating UIButton after auto-formatting UITextField

ios,swift,uibutton,switch-statement,uitextfield

If you have auto layout turned on, you should do it something like this, class ViewController: UIViewController { @IBOutlet weak var submitButton: UIButton! @IBOutlet weak var phoneNumber: UITextField! @IBOutlet weak var centerCon: NSLayoutConstraint! // IBOutlet to a centerX constraint on the button override func viewDidLoad() { centerCon.constant = self.view.frame.size.width/2 +...

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

ios,objective-c,uibutton

- (void)buttonClicked:(id)sender { // Do something when each button is clicked NSLog(@"Button title: %@", [sender titleForState:UIControlStateNormal]); } ...

Swift - UIButton with two lines of text

ios,swift,uibutton

There are two questions. I was wondering if it is possible to create a UIButton with two lines of text This is possible through using storyboard or programmatically. Storyboard: Notes: Change the Line Break Mode to Character Wrap, use Alt/Option + Enter key to enter a new line in the...