谁可以帮我这个代码?简单地说它不起作用,就像我尝试过的垂直滚动一样。我开始认为我的Xcode模拟器出了问题。这是代码:
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 30, 300, 400)];
[self.view addSubview:scroll];
[scroll setBackgroundColor:[UIColor redColor]];
{
UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1222, 400)];
[imageview setImage:[UIImage imageNamed:@"panorama_orizzonte_medio_big.jpg"]];
[scroll addSubview:imageview];
[self.view addSubview:scroll];
}
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
答案 0 :(得分:0)
设置UIImageView
后,您需要将scrollView
的{{1}}设置为contentSize
的{{1}},所以,如下所示:
imageView