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;
(void)viewWillAppear:(BOOL)animated{
UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,480)]; scrollview.showsVerticalScrollIndicator=YES; scrollview.scrollEnabled=YES; scrollview.userInteractionEnabled=YES; [self.view addSubview:scrollview]; scrollview.contentSize = CGSizeMake(320,960);//You Can Edit this with your require scrollview.pagingEnabled=YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
UIImageView* imageview1 =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]]; imageview1.frame=CGRectMake(18.0, 18, 285,50); [scrollview addSubview:imageview1];
UIImageView* imageview2 =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]]; imageview2.frame=CGRectMake(18.0, 78, 285,50); [scrollview addSubview:imageview2];
UIImageView* imageview3 =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]]; imageview3.frame=CGRectMake(18.0, 138, 285,50); [scrollview addSubview:imageview3];
UIImageView* imageview4 =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]]; imageview4.frame=CGRectMake(18.0, 198, 285,50); [scrollview addSubview:imageview4];