J'essaie d'ajouter le UIButton
à UIScrollView
.Ajout d'un UIButton à UIScrollView
J'ai ajouté le UIImageView
avec l'image de fond * (taille: 320 * 620) *. Ensuite, j'ai ajouté ce UIImageView
à UIScrollView
, et cela fonctionne très bien. Mais maintenant je veux ajouter UIButton
à la position: (60, 500); (sous l'écran qui apparaîtrait après le défilement).
J'ai essayé le code suivant, mais le bouton est ajouté sur UIView
pas sur scrollview. Le bouton ne s'affiche pas en haut.
code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = TRUE;
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SingleModelVar.png"]];
self.imageView = tempImageView;
[tempImageView release];
imageView.userInteractionEnabled = YES;
scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; //fit to screen
//scrollView.delaysContentTouches = NO;
scrollView.contentSize = CGSizeMake(320, imageView.frame.size.height); //imageView.frame.size.height=620 here
scrollView.maximumZoomScale = 4.0;
scrollView.minimumZoomScale = 0.75;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
//The Problem begins ..........
btnStartDate=[[UIButton alloc] initWithFrame:CGRectMake(60,500,100,20)];
[scrollView addSubview:btnStartDate];
//[self.view addSubview:btnStartDate];
btnEndDate=[[UIButton alloc] initWithFrame:CGRectMake(60,530,100,20)];
[scrollView addSubview:btnEndDate];
//[self.view addSubview:btnEndDate];
[scrollView addSubview:imageView];
[[self view] addSubview:scrollView];
}