I'm a newbie just begun with iPhone and Obj-C for a month now.
I have two buttons, both of them call the same function as follows
[play addTarget:self action:@selector(showQstn:) forControlEvents:UIControlEventTouchUpInside];
Inside the function showQstn, I want to know what button was tapped. Any idea?
Alternate ideas are welcome to...
I have a UIButton and I am trying to set a title and an image on it.
I would like to align the title for a UIButton to the left side and place an image aligned to the right. I am trying to get the look and feel of the button in Timer in Clocks app (the one which says "When Timer Ends").
I fiddled with contentHorizontalAlignment, conten...
I am trying to make a UIButton that grows when pressed. Currently i have the following code in my button's down event (courtesy of Tim's answer):
#define button_grow_amount 1.2
CGRect currentFrame = button.frame;
CGRect newFrame = CGRectMake(currentFrame.origin.x - currentFrame.size.width / button_grow_amount,
currentFrame.o...
I am currently using the following code in the AppDelegate to make a UIBarButtonItem act as a switch and adjusts a BOOL variable in the RootViewController Class:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
toggleSwitch = [[UIBarButtonItem alloc] initWithTitle:@"English" style:UIBarButtonItemStylePlain ta...
I'm dynamically creating UIButton's in my app. When I show the buttons I want to animate them. I can't seem to get the buttons to animate with this code:
UIImage *buttonBackground = [UIImage imageNamed:@"ButtonRed.png"];
for (NSInteger x = 0; x < 4; x++) {
CGRect btnFrame = CGRectMake(x * (buttonBackground.size.width+2),
...
Greetings,
I'm trying to get a ui button to have dual identities. If the user pushes it normally, an event fires (this works already). If the user pushes and holds it for some time period (2 seconds for example) a different event fires.
Any suggestions on a way to handle the "hold it down for 2 seconds" event?
Thanks!
...
I successfully created a custom keyboard that functions similarly to Apple's keyboard. There is one thing that remains different. On Apple's iPhone keyboard the user can swipe their finger across the keyboard and all of the keys they pass though will pop-up. On my keyboard this does not happen. Swiping your finger across will just re...
Hi, I'm learning how to develop on the iPhone, I bought a book called Beginning iPhone 3 development Exploring the SDK. After I bit I decided to ditch Interface Builder. I still design all my views in IB, but I write It all in code and only use the nib file to get the controls' frames.
So now I need to make a UIButton, and the documenta...
What happens if I release an autoreleased object? Its an autoreleased UIButton I want to release and the only way to create a UIButton is to use the convinience method buttonWithType:. Will it be released from memory like a normal object? Or should I just let the autoreleasepool take care of it? I wouldn't have made it autoreleased in th...
I have a UIButton on a UIView. I want to programatically figure out which image to display inside the button when the view is displayed. I have overriden the drawRect method in the UIView and used a setImage to display the desired image. However, when the view displays, sometimes it draws the desired image, and sometimes it does not. I h...
I have three buttons set up in Interface Builder, each tied via touchUpInside to btnSelection:
- (IBAction)btnSelection:(id)sender {
NSLog(@"tag: %i", [sender tag]);
}
In my console, the first click registers correctly (after a second or so delay, which seems a bit weird) but any subsequent touch of any of the 3 buttons results in...
Hi. I have a custom field that allows the user to enter text in a UITextField. To the left of the UITextField is a UIButton. Something like this:
ENTER YOUR NAME: [name input field]
In the about the UIButton has the text "ENTER YOUR NAME:" and the UITextField is the [name input field].
When the user taps the UITextField, the keyboard...
I've added a button to a tableview cell, but I'm having two problems with it:
1) I've invoked a setTarget:action: method on the button, but the action: method never gets called:
[playButton addTarget:self action:@selector(playButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
2) the cell itself ends up g...
Just created a new project in Xcode (View based), and tried creating a button like this programmatically, but it doesn't show. Why not?
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
CGRect rect = CGR...
Hi,
I am creating an application with call functionality, I want to have the phone image on the right hand side and the name of the contact on the left hand side. Currently this has been implemented by placing the 2 buttons side by side, hence if the user clicks on any of the buttons, the same functionality (calling the contact) happens...
Hello in my app i have some uiButtons added as subviews to a view like in the picture below.
when the user rotates the phone in landscape the views and buttons must change position to this:
initially when the view is in portrait mode the buttons respond to touches. If i tilt the phone the buttons move, everything looks ok like in the...
Hello again, I'm putting together an app that uses a keyboard (like the native iPhone one) that has symbols on the keys. My question is how to I change the location of a button when it is clicked (as the UIControlStateHighlighted images is bigger than the regular state).
Thanks for any help/pointers.
...
I have a simple UIButton and want to do something when the user touches it, but then moves the finger outside the button and untouches the screen. So that seems like I need to listen for the UIControlEventTouchUpOutside event.
In my view controller, I did this:
UIButton *bt = [[UIButton alloc] initWithFrame:rect];
[bt setBackgroundCol...
I'm trying to set the shadow colour on a UIButton, but all I seem to be able to get is a mid grey.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20, 20, 200, 100);
[button setTitle:@"a" forState:UIControlStateNormal];
[button addTarget:self
action:@selector(buttonPressed:)
for...
Hi,
I have a small iPhone app which I've created a button with some functionality in. My question is, how can I call this button without actually pressing it?
Any help would be appreciated!
Thanks
...