2011-03-22 133 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];