【问题标题】:button not appear in scrollview按钮未出现在滚动视图中
【发布时间】:2011-03-22 06:43:16
【问题描述】:

我正在为滚动视图编写代码并在其上添加按钮,但按钮未出现在滚动视图中。 我的代码

tableProductScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(75, 442, 874, 208)];
tableProductScrollView.delegate=self;
[tableProductScrollView setBackgroundColor:[UIColor clearColor]];
[tableProductScrollView  setCanCancelContentTouches:YES];
tableProductScrollView .indicatorStyle = UIScrollViewIndicatorStyleBlack;
tableProductScrollView .pagingEnabled = YES;
tableProductScrollView.showsVerticalScrollIndicator = YES;
[tableProductScrollView setContentSize:CGSizeMake(1748,208)];
[tableProductScrollView setScrollEnabled:YES];
[self.view addSubview:tableProductScrollView];  

CGRect frameProduct1 = CGRectMake(85, 445, 142, 150);
tableProduct1Button = [UIButton buttonWithType:UIButtonTypeCustom];
tableProduct1Button.frame = frameProduct1;  
UIImage *imgProduct1= [UIImage imageNamed:@"product6-small.png"];       
[tableProduct1Button setImage:imgProduct1 forState:UIControlStateNormal];
tableProduct1Button.backgroundColor = [UIColor clearColor];
tableProduct1Button.highlighted = YES;
//---add the action handler and set current class as target---
[tableProduct1Button addTarget:self
                             action:@selector(homeButtonAction)
                   forControlEvents:UIControlEventTouchUpInside];
[tableProductScrollView addSubview: tableProduct1Button];

请给我建议。

【问题讨论】:

    标签: iphone uiscrollview uibutton


    【解决方案1】:

    也许:

    UIButton *tableProduct1Button = [UI按钮 buttonWithType:UIButtonTypeCustom];

    【讨论】:

      【解决方案2】:

      尝试用某种颜色制作一个圆形矩形按钮,然后查看您是否能够看到按钮或检查框架。或者尝试为高亮状态设置图像。

      [tableProduct1Button setImage:image1 forState:UIControlStateHighlighted];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-04-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-17
        • 2012-03-10
        • 2016-05-06
        相关资源
        最近更新 更多