uibutton

UIButton in UIView in UIScrollView not loading properly

Kinda confusing title but oh well. I have a UIScrollView in my viewController, in that is 3 UIViews with some buttons in each. I download data from a server and populate it into the view and this works as soon as you start scrolling the UIScrollView, but sometimes the buttons only partially load. Usually its the button label without my...

uibutton text justify

I am trying to left justify text on a UIButton. It is middle justified by default. The following doesnt seem to work. Can someone suggest what may work. aButton.titleLabel.textAlignment = UITextAlignmentLeft; ...

UI design - Best way to deal with many UIButtons

Hi, I'm running into problems when dealing with a large amount of UIButtons in my interface. I was wondering if anyone had first hand experience with this and how they did it? When dealing with 30-80 buttons most simple, a couple of complex do you just use UIButton or do something different like drawRect, respond to touch events and g...

UIView subclass creating its own UIButtons

Hi all, I have subclassed UIView so I can draw some lines in it. In this UIView are a whole bunch of buttons which I decided to create as a method that drawRect calls after the lines are drawn. It works but sometimes only part of the button renders. If i remove the button creation and instead add the UIButton in the subclassed UIViews p...

Detect which button is pressed? (then action)

Hi guys! That's my very first post on SOF. I'm a new programmer at objective-c. Heres the "problem" i'm dealing with I created 2 UIbutton : one to pull an UIImageView from the top of the screen and the other to push it back. I have the code for the action** but i dont know how to relate it to an if-statement if(button1 pressed) then pu...

Animating incoming UITableView when a UIButton is pushed

The first view that appears in my app is a standard view with two UIButtons on it. When you select a button, a UITableView appears. I have set 'Anitmated' to 'YES', but when I tap the button, the UITableView does not slide onto the screen (it just appears). When I hit the "Back" button on the UITableView, it does animate as it slides off...

UIButton in UIView in UITableView = can't click the button

If I add the button straight everything goes fine. I'd really like to add it inside a view and still be able to click it. Here's the code: UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 60)] autorelease]; UIButton *footerButton = [UIButton buttonWithType:UIButtonTypeCustom]; footerButton.frame = CGRectMake(...

slide inside a button - touchdraginside

Hi all! I got an touchdraginside-action which is connected in IB with a button. -(IBAction)slide { } How can i check the start touch point in my button and how long the finger slides in this button? Can anybody help me, please? With this code a can check the touch in my view... But i dont know how this works with a button? -(void)...

Objective-C : Call a method from another class in addTarget:action:forControlEvents

Hi everyone, Here is my problem : I want to assign an Event on an UIButton. I use this method : - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents like this : [newsButton addTarget:self action:@selector(myEvent2) forControlEvents:UIControlEventTouchUpInside]; newsButton is my UIButton...

How to save/retrieve UIButton state ?

Hi all.. and this is my first question here ! I use UIButton with UISwitch functionality and i want to save/retrieve state of UIButton. Pls HELP! Resolved! Thanks Kalle and aBitObvious ! code i use : .h @interface RetinaViewController : UIViewController { IBOutlet UIButton *mybutton; } -(IBAction) toggleUIButtonImage:(id)send...

Cannot change UIButton origin

I'm trying to create a button programmatically and cannot change the origin. Here's the code: UIButton *newButton = [UIButton buttonWithType:UIButtonTypeCustom]; newButton.frame = CGRectMake(100, 200, 150, 50); [newButton setTitle:@"Hi There" forState:UIControlStateNormal]; [self.view addSubview:newButton]; The button shows up, but c...

UIButton modify image of UIImageView

Hi guys, I'm developing an iPhone app, and I need a little help. I created a button and I want when I click on to change an image's imageView by the button's one. the image and button : CGRect slot1Rect = CGRectMake(70, 90, 80, 110); UIImageView *slot1 = [[UIImageView alloc] initWithFrame:slot1Rect]; [slot1 setImage:[UIImage im...

Is there any way to create a UIButton which is not autoreleased, and still set it's UIButtonType?

UIButton has a single initializer buttonWithType. But this is a factory method and will create an autoreleased object. Of course we can do something like: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 50, 30)]; But in this case i will not be able to set the button's type as buttonType is a read only property. ...

iPhone/iPad stretchy, resizable buttons - subclassing UIButton

I want to be able to make custom buttons which have an image background using a scale9 type background image meaning the width of the button can be dynamic. I have seen example on the web of people doing this on a per button basis but it seems to me that wouldn't it be better to create a new object which subclasses UIButton which you can...

Add Target For UIButton Added to UIView Subclass Not Working on UIViewController

I have a custom UIButton added as subview to a UIView subclass. In my viewController I add the custom uiview as a subview to the controller's view. Then I try to add a target to uibutton (inside viewWillLoad), but the selector is never called. ...

Setting shadow color for the title of UIButton in the nib

Hi, I am developing a simple iPhone application. I want to set the shadow color for the title of a UIButton in the nib. Can someone help me in finding the set shadow color for the title in the nib? Thanks and Regards, Deepa ...

Why do my UIButtons look transparent in iOS4 when they looked fine in iOS3.1.x?

I have an app under development that worked fine under iOS 3.1.x. I was at a good break point, so I decided to upgrade my dev environment to XCode 3.2.4 + iOS4.1. My app has a number of UIButtons that I made colored using the "stretch a colored image as background" technique described elsewhere on StackOverflow: UIImage *myImage = [UII...

Change background color of UIButton when Highlighted

Hi I want to change the UIButton background color which user Tap on the button. I am showing background color using gradient, when user tap I need to change the gradient color. [btn setTitle: @"Next" forState:UIControlStateNormal]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = btn.bounds; gradient.cornerRadi...

UIButton - unwanted background well

I'm creating UIButtons (type = UIButtonTypeCustom) with a custom background drawn by an artist; unfortunately UIButton is adding an unwanted 'well' effect around the backgroundImage (as specified via setBackgroundImage). Is there a way to disable the well? It's not a simple drop shadow, so messing with the CALayer properties doesn't seem...

how to programmatically fake a touch even to a UIButton?

I'm writing some unit tests and, because of the nature of this particular app, it's important that I get as high up the UI chain as possible. So, what I'd like to do is programmatically trigger a button-press, as if the user had pressed the button in the GUI. (Yes, yes -- I could just call the IBAction selector but, again, the nature o...