【发布时间】:2016-07-16 20:01:46
【问题描述】:
需要水平滚动滚动视图并在其下添加图像。 它正在水平滚动,但即使在更改背景后也看不到我的图像。请在下面找到代码:-
#import "ViewController.h"
@interface ViewController () <UIScrollViewDelegate>
@property (nonatomic , weak) IBOutlet UIScrollView *scrollView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
for(int i=0; i<5; i++) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.window.frame.size.width/5)*i, 0, self.view.window.frame.size.width/5, 48)];
imageView.image = [UIImage imageNamed:@"t3"];
imageView.backgroundColor = [UIColor blackColor];
[_scrollView addSubview:imageView];
}
_scrollView.contentSize = CGSizeMake(self.view.window.frame.size.width, 48.0f);
[self.view addSubview:_scrollView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
【问题讨论】:
标签: ios objective-c iphone uiscrollview