Daniel
Daniel

Reputation: 1

Active buttons in scrollview

I have a source code where the main screen has 10 buttons (images buttons), each button is linked to sql database with tableview items, in the XIB I select which tag for each button, 1, 2, 3, 4..

I want make these buttons to scroll, how to do so?

I tried to convert the view into scrollview, then I have deleted the images, and created buttons in the scrollview, but now I do not know how to link each of the button to its tag in the tableview?

below is what I used:

@implementation mainViewController;

@synthesize master; @synthesize model;

Upvotes: 0

Views: 415

Answers (1)

BechD
BechD

Reputation: 73

Assingn a tag to the button when you create it:

[buttonName setTag:1];
[buttonName addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];

Then use:

-(void)aMethod:(UIButton *)button {
 if ([button tag] == 1) {
  ...do something...
 }
}

Hope this helps.

Upvotes: 0

Related Questions