Home Answers Viewqa Mobile-Applications space between buttons iPhone SDK

 
 


Java Coder
space between buttons iPhone SDK
4 Answer(s)      2 years and 5 months ago
Posted in : MobileApplications

Hi, can any one please explain how to add space between UIButtons in iPhone SDK. Actually i am creating Multiple UIButton's and added them to my UIScrollView. But problem is that those buttons are placed over each other. Please tell me how can i set fix margin between buttons.

Thanks!

View Answers

January 7, 2011 at 5:47 PM


//Creating UIButtons
    int offset = 0;
    for (int row = 0; row<10; row++){
        for (int col = 0; col<2;col++) {
            offset +=0;

            UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            aButton.frame = CGRectMake(5+col*150+offset,10+row*190, 160, 180);
            aButton.bounds = CGRectMake(5, 0, 140.0, 180.0);

            UIImage *buttonImageNormal = [UIImage imageNamed:@"button3.png"];
            [aButton setBackgroundImage:buttonImageNormal forState:UIControlStateNormal];

            [aButton setTitle:@"Play" forState:UIControlStateNormal];
            [aButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];    


            [self.iScrollView addSubview:aButton];
        }
    }

March 27, 2011 at 9:02 AM


Hello,

Can you please comment the code, I do not understand how the code helps, I am trying to create a multiple buttons on only the x axis and want to include spaces between each button, this is what i have so far can anyone help.

NSMutableArray* buttonArray = [[NSMutableArray alloc] init];

int offset = 0;

for(int i = 0; i < 6; i++) {

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

[btn setFrame:CGRectMake((0+offset), 0, 55, 55)];

[btn setTitle:[NSString stringWithFormat:@"Button %d", i+1] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

[buttonArray addObject:btn];

//move button by offset offset += 10;

[btn release];

}

Can anyone help?


March 27, 2011 at 9:03 AM


sorry the offset += 10; is not commented just posted like that see below agin for correct code

NSMutableArray* buttonArray = [[NSMutableArray alloc] init];

int offset = 0;

for(int i = 0; i < 6; i++) {

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

[btn setFrame:CGRectMake((0+offset), 0, 55, 55)];

[btn setTitle:[NSString stringWithFormat:@"Button %d", i+1] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

[buttonArray addObject:btn];

//move button by offset offset += 10;

[btn release];

}


March 27, 2011 at 9:04 AM


NSMutableArray* buttonArray = [[NSMutableArray alloc] init];

int offset = 0;

for(int i = 0; i < 6; i++) {

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

[btn setFrame:CGRectMake((0+offset), 0, 55, 55)];

[btn setTitle:[NSString stringWithFormat:@"Button %d", i+1] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

[buttonArray addObject:btn];

offset += 10;

[btn release];

}









Related Pages:
space between buttons iPhone SDK
space between buttons iPhone SDK  Hi, can any one please explain how to add space between UIButtons in iPhone SDK. Actually i am creating Multiple UIButton's and added them to my UIScrollView. But problem is that those buttons
Installing iPhone SDK
Downloading and Installing iPhone SDK?       Downloading SDK for iPhone.... The Apple's SDK enables the programmers to develop software for iPhone
iPhone SDK Examples
. are presented here. We will discuss all the UI and other components of the iPhone SDK...While developing the iPhone program, many times you need some code to copy... components. Windows Buttons Fonts Text Orientation
what is json in iphone sdk
what is json in iphone sdk  What is json in iphone sdk? Is this a library and when i need to include JSon in my iPhone SDK App
iphone sdk-objective c
iphone sdk-objective c  how to delete random value which is got from the random function in an array
What is iPhone SDK?
What is iPhone SDK?       What is iPhone SDK? The iPhone SDK or iPhone software... and build the software for the iPhone. The iPhone SDK includes the API and components
iPhone SDK UIAlertView
iPhone SDK UIAlertView  Hi, How can i use the iPhone UIAlertView to create a message box. Can any help or provide example or online reference. Thanks
Iphone SDK Development
Iphone SDK Development  Hi, I am a beginner in the Mobile applications platform. From where i get the online help or information related to Iphone SDK Development Apps help. Please provides me reference sites.. Thanks
activity indicator for iphone sdk
activity indicator for iphone sdk  Setting the UIActivity indicator in search bar for iPhone SDK.   [NSThread detachNewThreadSelector:@selector(threadStartAnimating:) toTarget:self withObject:nil];   -(void
iPhone SDK Multiple UIButton
iPhone SDK Multiple UIButton  In my iphone SDK program.. i wanted... into database. Any help is appreciated. Thanks in Advance!   iPhone SDK...:myButton]; iPhone SDK Creating Multiple UIButton for (int row = 0; row<4
implement core data iphone sdk
implement core data iphone sdk  How to implement core data in iPhone SDK? Please Help
Hyperlink on UILabel iPhone SDK
Hyperlink on UILabel iPhone SDK  Hi, I wanted to set a hyperlink on UILabel in my iPhone application. Can anyone suggest me how to do it? Thanks
iPhone Capturing Screen SDK
iPhone Capturing Screen SDK  Creating an application to capture the screen shots from iPhone. In objective c is there any class that make it enable..?   UIGraphicsBeginImageContext(CGSizeMake(480,320)); UIImage* result
share data iphone sdk
share data iphone sdk  How to share data in iPhone application? Actually i want the sharing feature in my iPhone application. Thanks!   You can use the emailing feature in your iPhone application to the share data
parse url iphone sdk
parse url iphone sdk  How can i parse two different URL's using NSXMLParser
Page curl effect iPhone SDK
Page curl effect iPhone SDK  How to get the page curl effect in my iPhone application? Please suggest or give an example to get the page curl effect in iPhone SDK application. Thanks.   In objective c there is a method
space around/between my images
space around/between my images  How do I eliminate the space around/between my images
license for google maps - iPhone SDK
license for google maps - iPhone SDK  Do i need a license to display the locations on google map in my iPhone application
creating dynamic buttons in iphone
creating dynamic buttons in iphone  i Have a UIView and i wanted to create a multiple buttons to that should come on view load. It will be great if that can be removed after sometime or required time.   -(void
iPhone SDK Tutorials and Examples
The best collection of iPhone development tutorials and examples specially developed to learn iPhone SDK programming easily. These iPhone SDK tutorials... we will explain you the iPhone SDK programming concepts in detail. You
How to open URL in iPhone SDK
How to open URL in iPhone SDK  In my iPhone application ..i wanted to open a url in the application. Is it possible? If yes how will i come back to my application
add plist file iphone sdk
add plist file iphone sdk  how to add plist file in XCode
add plist file iphone sdk
add plist file iphone sdk  how to add plist file in XCode
rate my app iphone SDK
rate my app iphone SDK  How can i enable "Rate and Review Application" feature of my application on iTune
remove from superview iphone sdk
remove from superview iphone sdk  How to remove the old view from super-view and add the new view safely? My main concern is memory leak.. so, please suggest how can i do it without facing a memory leak. Thanks
iPhone 3.0 SDK
iPhone 3.0 SDK delivers on its Promise  ... release is the beta version of the third iPhone SDK. The iPhone 3.0 SDK beta allows..., included in the iPhone 3.0 SDK release. The PNS allows third party servers to send
go back to previous view iphone sdk
go back to previous view iphone sdk  How to go back to previous view iphone sdk?    - (IBAction)backView:(id)sender { [self.navigationController popViewControllerAnimated:YES
How do SEL and @selector work in iphone sdk?
How do SEL and @selector work in iphone sdk?  How do SEL and @selector work in iphone sdk?   SEL is a type that represents a selector in Objective-C. The @selector() keyword returns a SEL that you describe
iPhone SDK Comparing Strings
In this section I will show you how you can compare the two strings in your iPhone SDK Project. To compare the Strings you will have to use... of comparing strings in iPhone sdk programs. The == operator only compares
iPhone Application Development,Mobile iPhone Application Development,iPhone Porting Solutions
the iPhone SDK to add value to your existing applications. iPhone Web... iPhone Application Development Services Rose India iPhone Application Development Services iPhone 3G is Apple developed smartphone
iPhone Game Applications Development, iPhone Game Porting Services, iPhone Game Designing
India can develop games using the iPhone SDK to deliver high end games... iPhone Game Applications Development iPhone Game Development... the way we listen to music and download it, the iPhone has revolutionalized mobile
Use of SVOX SDK 5.0.0 for text to speech in iphone project
Use of SVOX SDK 5.0.0 for text to speech in iphone project  how to implement svox sdk for text to speech in xcode. I need a sort of exmaple for it...awaitinh ofr your reply thanks
Use of SVOX SDK 5.0.0 for text to speech in iphone project
Use of SVOX SDK 5.0.0 for text to speech in iphone project  how to implement svox sdk for text to speech in xcode. I need a sort of exmaple for it...awaitinh ofr your reply thanks
Current Date iPhone SDK
Current Date iPhone SDK In this example, you'll find out how to get current date & day in iPhone SDK. We'll also write a method to print the day and date...! If not lets first find out what is NSdateFormatter in iPhone SDK programming
iPhone 3G vs iPhone 2G
and broader. Although this difference between the old and new iphone is very... to the main difference between the iPhone 2G and the iPhone 3G, GPS and 3G. For many these are the real difference between the old and the new iPhone and raison d'etre
iPhone Application Development
be developed using a variety of tools like Apple's free iPhone SDK development tool... because of the relatively smaller screen size vis-à-vis a PC. iPhone SDK... in an iPhone simulator or device. The DashCode bundled with the iPhone SDK enables web
Looking for change password in iphone application sdk using sqlite
Looking for change password in iphone application sdk using sqlite  i am trying to change old password in my iphone application my code is below please help how can i do .... -(IBAction)matchpassword{ //sqlite3_stmt
how to create directed line between two buttons when i clicked there
how to create directed line between two buttons when i clicked there  Hi I have to create a topology between 6 nodes. 6 nodes are created as 6 buttons and when i clicked in first button and then on second button a directed
iPhone Application Development
in the iPhone SDK. Objective-C gives flexibility to Cocoa Framework...iPhone Application Development For developing any application, Apple.... The tools offered by Apple for the development of apps for iPhone are same used
Buttons
Java: Buttons There are many kinds of buttons, all derived from..., ButtonGroup Radio buttons are a group of buttons that can have at most one.... JToggleButton Changes between two states: on and off. Stays on/off until
Orientation iPhone SDK
Orientation iPhone SDK In this tutorial we are going to show you how to set orientation in iPhone application. While developing the application in iPhone please keep in mind that landscape orientation is not possible in the case
iPhone play, pause and stop playing music
iPhone play, pause and stop playing music This is the small iPhone SDK... ViewController.xib file and add three buttons for the different actions and hooked them...]; } The final application will look like this.. Just click on the buttons to play
Set Space Ratio and Alignment
alignment. You can make pdf with no space between the characters of a word... the alignment to be justified, the space between the words can be stretched, as well as the space between the characters of a word. The default
Buttons
Buttons  I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances and other appliances.I want to check for the appliance chosen when the required
iPhone
of tools like Apple's free iPhone SDK development tool or a number of other... Objective C tutorials.   iPhone SDK programming Learn iPhone... iPhone      
Mouse Buttons, Modifier Keys
SDK 1.4. There are two ways to test the mouse buttons and modifier keys... Java NotesMouse Buttons, Modifier Keys Mouse Buttons. Java supports up to three mouse buttons. Even if your mouse doesn't have three separate
Hello World iphone Example
of creating your first "Hello World" app in iphone SDK. As this tutorial... in Iphone SDK: 1. Creating a new project:     Double click...Hello World iphone with Example In the given tutorial you will be creating
All iPhone Tips and Tricks
thinking it to be in a dark environment. Custom iPhone Buttons Tips n Tricks... All iPhone Tips and Tricks       If you are looking for some cool iPhone 3G tips n tricks
How to remove the space between a JComponent and its Grid border while using GridBagLayout?
How to remove the space between a JComponent and its Grid border while using... space between the Label text and the TextBox.Could anyone help me to reduce the space between those Components? Thanks for ur help in advance.   import
iPhone 3G Comparison
smartphone prize. Here we do a general comparison between the iPhone 3G and other... its slider. Also it has many front buttons unlike the button less iPhone... iPhone 3G Comparison