2012-03-31 254 views
0

我有一個UIScrollVIew。它包含具有不同控件的視圖。我將它們全部添加到視圖中,然後將視圖添加到UIScrollView。滾動不被激活,並且內容不居中。下面是代碼:UIScrollVIew不滾動

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    CGRect frame = texto.frame; 
    frame.size.height = texto.contentSize.height; 
    texto.frame = frame; 

    [self configureView]; 

    [self.scrollView addSubview:self.contentView]; 
    self.scrollView.contentSize = self.contentView.bounds.size; 
    self.contentView.userInteractionEnabled= NO; 
    self.scrollView.userInteractionEnabled=TRUE; 

} 

-(void)configureView{ 

    self.texto.text = self.newsDetail.text; 

    NSData *imageData= [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:self.newsDetail.image_large]]; 

    self.imagen.image = [UIImage imageWithData:imageData]; 

    self.fecha.text = self.newsDetail.datePublish; 

    self.titulo.text = self.newsDetail.title; 


} 

頁眉代碼:

@interface detailNewsController : UIViewController{ 

UIScrollView * __weak scrollView; 
UIView  * __weak contentView; 

} 

@property (nonatomic, strong) news *newsDetail; 

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView; 

@property (weak, nonatomic) IBOutlet UIView * contentView; 

@property (strong, nonatomic) IBOutlet UIImageView *imagen; 

@property (strong, nonatomic) IBOutlet UILabel *fecha; 
@property (strong, nonatomic) IBOutlet UILabel *titulo; 

@property (strong, nonatomic) IBOutlet UITextView *texto; 

-(void) configureView; 

回答

0

我看到你有一個代碼變量鏈接您的UIScrollView。因此,如果你啓用了垂直滾動(或水平的滾動,如果你需要的話),請檢查界面生成器。

+0

嗨gargo,在界面生成器中我有這個ContenView - > imagen,fecha,titulo,文本。但ScrollView不在IB中。也許這是問題所在。謝謝。 – theomen 2012-04-01 09:27:00

+0

也許默認情況下它不是可滾動的,你應該自己設置它 – Gargo 2012-04-01 12:59:17

+0

你是對的。解決了。非常感謝。 – theomen 2012-04-01 14:11:54