0

I want to add total 5 button at bottom of screen but only four will be visible at first time loading of nib.

and if user press first button it will be disappear with animation and second button will come at place of first . and now in screen one more button (button 5 ) at last.

to make it more clear i am adding image.

screen 1. when nib loaded first time.

screen 2. when button 1 pressed.

screen 3. when button 2 pressed.

enter image description here

iosDev
  • 604
  • 3
  • 12
  • 28

2 Answers2

1

AS U HAVENT POSTED ANY CODE THAT U'VE TRIED.

So Here is some idea I can suggest to u.

If u want to disappear the button when pressed then, instead of removing it from the view u can keep it there but only make it invisible , may be by setting properties of "visual appearance of view"(look for UIView class reference) eg. alpha value,hidden property.

Once u invisible it, then make it visible after some delay eg.1/2 second. Once button is visible then CHANGE the label text.

In case ur, u'll need to set UILabel text of all four button; by incrementing label-text int value by 1.

hp iOS Coder
  • 3,230
  • 2
  • 23
  • 39
1

How about something like this? It's not perfect so you'll have to play with it but it should get you started in the right direction...

in your .h

IBOutlet UIButton *firstButton, *secondButton, *thirdButton, *fourthButton
NSArray *buttonsArray;

in your .m

-(void)viewDidLoad{
    // VDL stuff
    buttonsArray = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", @"Five", @"Six", nil];
    [firstButton setTitle:[buttonsArray objectAtIndex:0]];
    [firstButton setTag:0];
    // initial setup of the other three buttons works the same way
}

-(IBAction)updateButtons:(id)sender{
    UIButton *btn = (UIButton*)sender;
    int index = btn.tag;
    for(int i = 0; i <4; i++){
        if([buttonsArray count] > index+i){
            switch(i){
                case 0:;
                    [firstButton setTitle:[buttonsArray objectAtIndex:i+index]];
                    [firstButton setTag:i+index];
                    break;
                case 1:; //secondButton
                    break;
                case 2:; //thirdButton
                    break;
                case 3:; //fourthButton
                    break;
            }
        }else{
            break;
        }
    }
}

Then all you need to do is connect the four on-screen buttons to the action and in the else you'll need some logic (pretty much the same as the switch-case above) to hide ones once you get towards the end of the array if that's what you want to do.

acorc
  • 360
  • 1
  • 8