Closed kimg closed 12 years ago
Yes, you can put whatever you want in the view you create in the easyTableView:viewForRect: delegate method.
Ok, I can add a picture but then i miss a label beneath the picture. i've been experimenting to see if i can get a picture and below the picture a very short text.
(UIView )easyTableView:(EasyTableView )easyTableView viewForRect:(CGRect)rect { CGRect labelRect = CGRectMake(10, 240, rect.size.width-10, rect.size.height-270); UILabel *label = [[UILabel alloc] initWithFrame:labelRect]; label.textAlignment = UITextAlignmentCenter; label.textColor = [UIColor whiteColor]; label.font = [UIFont boldSystemFontOfSize:20];
label.backgroundColor = [UIColor lightGrayColor];
CGRect picRect = CGRectMake(10, 100, rect.size.width-10, rect.size.height-100);
UIImageView borderView = [[UIImageView alloc] initWithFrame:picRect];
borderView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
NSString borderImageName = @"image_samplecover.png";
borderView.tag = BORDER_VIEW_TAG;
borderView.image = [UIImage imageNamed:borderImageName];
[label addSubview:borderView]; borderView = nil;
return label; }
i see the label and it has the correct height ans so on. but the picture never shows. i guess i have to add the two components: the picture rect and the label. but i can't get it to work. do you have a suggestion. sorry to bother you again...
kim
Create a container view and put the label and image view in the container view. Do not add the imageView as a subview of the label. Also, you have a memory leak. Replace borderView = nil; with [borderView release];
another practical problem: is it possible to have different images in the scroll cells? as far as i can tell viewForRect is the place where the layout of the cells is done. but assume that i have 21 different pictures i'd like to scroll through - i can't see that the function is called pr cell. am i wrong?
kim
You would set different images to a UIImageView object in the cell's view hierarchy. If you already have all of the images local to the device, do this in the delegate method:
Otherwise, if the images are being loaded from a remote URL, set the UIImageView object in the cell's view hierarchy using the following method:
You should know what the index value is from your own image loading logic.
kim,
I updated the project with an example of how to use EasyTableView to display images loaded from a remote server, Flickr in this particular case. Just tap the info icon. You may need to do it a few times if you receive an error.
Aleksey
I wonder if it is possible to use an image instead of the numbering in the scrollers.
does take some kind of rewrite to do so?
br kim