2011-03-22 84 views
0

我正在编写滚动视图和添加按钮的代码,但按钮不出现在滚动视图中。 我的代码按钮不出现在滚动视图

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]; 

请给我建议。

回答

0

也许:

的UIButton * tableProduct1Button = [UIButton的 buttonWithType:UIButtonTypeCustom];

0

尝试制作具有某种颜色的圆形矩形按钮,然后查看您是否能够看到按钮或检查框架。或尝试设置突出显示状态的图像。

[tableProduct1Button setImage:image1 forState:UIControlStateHighlighted];