无法在iOS中的滚动视图上设置按钮

时间:2015-12-18 11:05:15

标签: ios

我正在设置滚动视图,在该视图上我有两个按钮,但是,按钮没有显示在图像视图上。当我设置滚动视图。我想要一个图像上的按钮:

-(void)addScrollView{

    scrollview.contentSize=CGSizeMake(1280,960);

    CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];

    scrollview=[[UIScrollView alloc] initWithFrame:fullScreenRect];

    scrollview.contentSize=CGSizeMake(320,758);

    imageview = [[UIImageView alloc]initWithImage:

                 [UIImage imageNamed:@"IPHome Page Final.jpg"]];

    [scrollview addSubview:imageview];

    scrollview.minimumZoomScale = 0.5;

    scrollview.maximumZoomScale = 3;

    scrollview.contentSize = CGSizeMake(imageview.frame.size.width,

                                          imageview

                                          .frame.size.height);

    scrollview.delegate = self;
    [imageview addSubview:CameraButton];
    [imageview addSubview:SoundButton];
    [self.view addSubview:scrollview];

}

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您的代码会处理按钮上发生的事件(例如在内部/外部触摸..etc)您必须先创建按钮。通过UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]以编程方式创建按钮,或将其添加到“界面”构建器并为其创建IBOutlet

相关问题