我已經創建了UIScrollView
,現在我正試圖在滾動視圖上放置一個UIButton
。但是,當我構建並運行應用程序滾動視圖仍然正常工作,但我看不到UIButton
。UIScrollView涵蓋UIButton
我在界面構建器中鏈接UIButton IBOutlet
。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
scrollView.backgroundColor = [UIColor blackColor];
scrollView.delegate = self;
scrollView.bounces = NO;
backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"auckland-300.jpg"]];
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"249a-134206f1d00-1342071f5d9.ImgPlayerAUCKLAND.png"]];
// Note here you should size the container view appropriately and layout backgroundImage and image accordingly.
containerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,601,601)];
playButton = [[UIButton alloc] init]; //test button cannot see it.
[containerView addSubview:backgroundImage];
[containerView addSubview:image];
scrollView.contentSize = containerView.frame.size;
[scrollView addSubview:containerView];
scrollView.minimumZoomScale = 0.5;
scrollView.maximumZoomScale = 31.0;
[scrollView setZoomScale:scrollView.minimumZoomScale];
self.view = scrollView;
}
任何幫助,將不勝感激
想要在* scrollView或* scrollView中添加UIButton *?在scrollview之上的 – akashivskyy
,所以我仍然可以捏縮放和滾動而不影響按鈕。 –