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;
嗨gargo,在界面生成器中我有这个ContenView - > imagen,fecha,titulo,文本。但ScrollView不在IB中。也许这是问题所在。谢谢。 – theomen 2012-04-01 09:27:00
也许默认情况下它不是可滚动的,你应该自己设置它 – Gargo 2012-04-01 12:59:17
你是对的。解决了。非常感谢。 – theomen 2012-04-01 14:11:54