0
我試圖添加UIButton
到UIScrollView
。添加一個UIButton到的UIScrollView
我已經添加了與UIImageView
背景圖像*(尺寸:320×620)*。 然後我說這個UIImageView
到UIScrollView
,並能正常工作。
但現在我想添加UIButton
在位置:(60,500);(以下滾動後似乎該屏幕)。
我試過下面的代碼,但是在UIView
上加上的按鈕不在scrollview上。按鈕是沒有得到顯示在頂部。
代碼:
- (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];
}