I have a UIScrollView
that has an outlet and in my implementation file, I've even programmatically added the objects that I need on there. When I run my program, the NSLog
states that it's up but on the simulator, it's showing nothing. There's not even any scrolling action visible.
I've done it before and double checked with the other view controller and everything seems to line up but it's still not wanting to show. I declared the IBOutlet
in .h and in .m I've set a NSDictionary
in the array's method that contains the objects I need on the scrollview.
I then tell it to add it to the subview, [self.scrollview addSubview:someView]
; where someview is the main object that has other objects laying on top. This has worked before but for some reason, is failing to work at this time. I've also ensured I added the method for the array to the viewDidLoad
method. I've connected the outlet in Storyboard but get no visual result. I'm using lorempixel to populate the images and as stated before, it's working on another VC but not on this one. It's probably something simple I'm missing. Thanks for the help.
-(void)addItemsToThis:(NSMutableArray *)anArray {
int i = 0;
float contentHeight = firstRowGutterY;
for (NSDictionary *item in checkout) {
int row = (int) i / 3;
float xOffset = i % 3 == 0 ? firstColumnGutterX : (i % 3) * itemContainerWidth + (xGutter * (i % 3) + firstColumnGutterX);
float yOffset = i < 3 ? firstRowGutterY : firstRowGutterY + (row * itemContainerHeight) + (row * yGutter);
UIView *itemCont = [[UIView alloc] initWithFrame:CGRectMake(xOffset, yOffset, itemContainerWidth, itemContainerHeight)];
[itemCont setBackgroundColor:[UIColor clearColor]];
UIView *whiteBox = [[UIView alloc] initWithFrame:CGRectMake(0, 6, 88, 112)];
[whiteBox setBackgroundColor:[UIColor whiteColor]];
UIButton *delete = [[UIButton alloc]initWithFrame:CGRectMake(70, 2, 24, 26)];
UIImage *main = [UIImage imageWithData:[NSData dataWithContentsOfURL:[item objectForKey:@"image"]]];
UIButton *imageBtn = [[UIButton alloc]initWithFrame:CGRectMake(6, 6, 78, 78)];
[imageBtn setBackgroundImage:main forState:UIControlStateNormal];
[whiteBox addSubview:imageBtn];
[itemCont addSubview:whiteBox];
[itemCont addSubview:delete];
[self.scrollview addSubview:itemCont];
i++;
if (i % 3 == 0) {
contentHeight += itemContainerHeight + yGutter;
}
NSLog(@"%f", contentHeight);
}
self.scrollview.contentSize = CGSizeMake(self.scrollview.contentSize.width, contentHeight);
}