uibutton

Create a UIButton with (or without) memory

I'm trying to add a UIButton with code (not Interface Builder). Some examples say you MUST alloc and release memory for the button. Others use buttonWithType and magically create a button without alloc'ing any memory at all. How is that possible? (Both seem to work fine.) Which of the 2 methods do I want to use... and when? Are th...

Updating imageView on UIButton within UITableViewCell

I have custom UITableViewCells (created in interface builder) which are used for a static UITableView which for the sake of argument I will call the AddUserTableViewController (i.e. I do not use autoreleased cells as I only have 5 rows). In the top cell (used for the user name) I have embedded a UIButton which I use to open an UIActionS...

Keep iPhone UIButton Highlighted

I have the following code snippets: @interface Foo: UIViewController { ... UIButton *myButton; ... } @implementation Foo (void) viewDidLoad { ... myButton.highlighted = YES; ... } When I run the app, the button is highlighted in blue (default behavior). It works as I expected. But after pressing the button once, the button i...

UIButton Buy Now effect

Hi. I want to make a "Buy Now" button in my Application, which should work the same way as the one in the App Store, but I dont know how to resize the UIButton with an animation. I have tried the following, but it resized the button at once and not as an animation: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration...

How is the purchase button animation made in the Apps Store?

I've tried creating two UIButtons programatically as described here. This works great but there doesn't seem to be a simple transition for expanding the UIButton on the left as seen in the Apps Store. ...

Why do I get a memory leak when adding a button as a subview?

I have an app that uses a tableview, along with a UIButton that I add as a subview to each custom cell, like this: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; chec...

How to add a drop shadow to a UIButton?

I would like to add a drop shadow to a UIButton. I tried to use self.layer.shadow* properties. Those properties work in UIView, but they behave differently in UIButton. I would really appreciate it if I could get any pointers to draw the drop shadow. Thank you! self.layer.cornerRadius = 8.0f; self.layer.masksToBounds = YES; self.layer.b...

how to get the x and y position of a UI button IPhone

Hi, Could somebody show me how to get the x and y position of a UIButton in cocoa? The button moves on the screen when clicked and I want to use it's current position to position another UIBUtton relative to it. I've tried using CGRect rect=[myButton imageRectForContentRect]; The compiler tells me that myButton may not respond to i...

How to set target and action for UIBarButtonItem at runtime

Tried this but only works for UIButton: [btn setTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; ...

iPhone Circular Progress Indicator. CGContextRef. Draw on Demand.

Ola Folks, Once again, I want to leech experience, information and knowledge from those who have more of them than I do. Granted, I do make some effort looking for questions to answer... :) Anyway, I want to draw an image that would effectively be a circular progress indicator on a UIButton. Because the image is supposed to represent p...

How can I create a ToggleButton in Obj-C? Skin the UISwitch or subclass the UIButton?

How can I create a ToggleButton in Obj-C? Skin the UISwitch or subclass the UIButton? ...

iPhone UIBarButtonItem setCustomView: method?

Hi, I want to customize my UIBarButtonItem's appearance. Here's the code I'm currently using: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(267, 6, 48, 30)]; [editButton setCustomView:button]; // editButton is the UIBarButtonItem Unfortunately, the UIButton does not get drawn, i.e. it's 100% transparent. I know the b...

iPhone: adding button to scrollview makes button inaccessible to interaction

For some reason, the button initialized in the addBook method of my viewController won't respond to touches. The selector I've assigned to it never triggers, nor does the UIControlStateHighlighted image ever appear when tapping on the image. Is there something intercepting touches before they get to the UIButton, or is its interactivity...

UIButton setBackgroundImage consumes a lot of memory

I'm using the following code: UIImage *buttonImage; if (p.placeImage != nil) { buttonImage = [UIImage imageWithData:p.placeImage]; } else { buttonImage = [UIImage imageNamed:@"bg_place_noimg.png"]; } [imageButton setBackgroundImage:buttonImage forState:UIControlStateNormal]; When executing the app with Instruments I can see ...

Calculator application, pupulating textfield from buttons, iphone

I am creating a simple calculator application. I have 10 buttons labelled 0 through 9, and 5 buttons for the operations. I have an uitextfied which should be populated from the buttons. ie when the user click button 1, 1 should be entered in the field and so on. Also the value entered should be there even if the user taps another one. ho...

Smaller active area for custom UIBarButtonItem

I have a UINavigationBar with a custom UIBarButtonItem (which uses a UIButton as its custom view). The problem is: the active area of the custom button is much too large, if I tap at least 40 pixels outside the button, it still gets registered as a tap on the button. This results in accidental taps. How can I reduce the active area on th...

how to handle button onclick action in iPhone without using interface builder?

how to handle button onclick action in iPhone without using interface builder? ...

iPhone UIButton TitleLabel text?

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, cellWidth - 2, cellHeight - 2); UIButton button = new UIButton (frame); button.TitleLabel.Tex...

Why is the control flow not entering @selector(methodname)?

I've written some code for a button action. First I'm creating a button "UI", and its onAction should call ButtonListener in @selector in addTarget. But it doesn't seem to be entering the @selector(UIButtonListener) method. Here's my code: UIButton_G_obj = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; UIButton_G_obj.fram...

Terminating app due to uncaught exception 'NSInvalidArgumentException', in iPhone programming

hello, i've the following code for button creation and on action of button , i'm calling buildUI method CGRect cgRct = CGRectMake(10 ,30 ,400, 320); //define size and position of view subMainView_G_obj = [[UIView alloc] initWithFrame:cgRct]; //initilize the view subMainView_G_obj.autoresizesSubviews = YES; //set view property ov ...