Reputation: 1170
Hi guys I'm unable to make the image file the custom uitableview cell i made. The image is so small and i don't know how to enlarge it. Thnx in advance for the help.
#import <UIKit/UIKit.h>
@interface customCell : UITableViewCell
{
//UILabel *frontLabel;
}
@property(nonatomic , strong) IBOutlet UILabel *label;
@property(nonatomic , strong) IBOutlet UILabel *label2;
@property(nonatomic , strong) IBOutlet UIImageView *imgView;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
customCell * cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[customCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
// cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
User * user = [self.list objectAtIndex: indexPath.row];
cell.label.text = user.username;
NSString *url = user.profilePic;
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
cell.imageView.contentMode =UIViewContentModeScaleAspectFit;
cell.imageView.image =image;
return cell;
}
Upvotes: 0
Views: 352
Reputation: 14815
In your customCell
class (btw all classes should start with a capital letter, properties and variables should be lowercase), you just need to set the frame
property of your imageView
object to the correct size and position you want.
Something like imageView.frame = CGRectMake(10., 10., 50., 50.)
where the first two parameters are the x and y position of the top right corner of the image view, and the second two parameters are the width and height.
Or, since you have those properties specified as IBOutlet's, if you're using a XIB file for the layout, you should have the size setup already in there.
Without seeing a screenshot of Interface Builder for the XIB or the implementation code for customCell
, that's the best I can help.
Upvotes: 1