Howdy...
I'm having a problem trying to load a button using a subview.
What i would like is for my buttons to appear next to each other in rows and colums to be able to see all the photos (as buttons).
Here is where i load my viewController
Code:
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button;
UIImage *thumbnail;
int images_count = self.photoCount;
for (int i=0; i<=images_count-1; i++) {
thumbnail = [thumbnails objectAtIndex:i];
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:thumbnail forState:UIControlStateNormal];
button.frame = CGRectMake(ThumbnailSizeWidth * (i % THUMBNAIL_COLS) + PADDING * (i % THUMBNAIL_COLS) + PADDING,
ThumbnailSizeHeight * (i / THUMBNAIL_COLS) + PADDING * (i / THUMBNAIL_COLS) + PADDING + PADDING_TOP,
ThumbnailSizeWidth, ThumbnailSizeHeight);
[self.scrollView addSubview:button];
}
}
Using the debugger my for loop goes all the way throught the for loop and it seems to crash after the function who calls this view is done
Code:
- (void)showPhotoAlbum:(NSIndexPath *)indexPath {
AlbumViewController *photoAlbum = [[AlbumViewController alloc] init];
photoAlbum.thumbnails = [thumbnails objectAtIndex:indexPath.row];
photoAlbum.photos = [photos objectAtIndex:indexPath.row];
photoAlbum.photoCount = [[numPhotos objectAtIndex:indexPath.row] intValue];
photoAlbum.title = [title objectAtIndex:indexPath.row];
[self.navigationController pushViewController:photoAlbum animated:YES];
[photoAlbum release];
[activityIndicator stopAnimating];
}
The error i am getting is
*** -[NSCFString size]: unrecognized selector sent to instance 0x4147b90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString size]: unrecognized selector sent to instance 0x4147b90'
I've been looking into this error and dont understnd what it is refering to.
If someone could please help.
Forgot to mention... my nib file has a UISrcollView which is linked to the ScrollView in my ViewController. My mainview is of type UiScrollView, and is connected to the File's Owner