【发布时间】:2012-01-17 07:46:17
【问题描述】:
我创建了一个UIScrollView,现在正尝试在滚动视图上放置一个UIButton。但是,当我构建并运行应用程序时,滚动视图仍然可以正常工作,但我看不到 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;
}
任何帮助将不胜感激
【问题讨论】:
-
你想在 in scrollView 或 above scrollView 中添加 UIButton?
-
在滚动视图上方,所以我仍然可以在不影响按钮的情况下进行缩放和滚动。
标签: iphone ios uiscrollview uibutton iboutlet