Hi All,
I am trying to do a customised UITableview by drawing different images...
I could not really understand view controller based implementations, so i thought i would write mine. in fact i find it easier to write without using nib files
i wrote following code
unfortunately code never comes to cellForRowAtIndexPathNSIndexPath nor to drawrect of cellview ...
what am i doing wrong ?
////////////////////////////////////////
____________________________
inherited from TableViewCell
_____________________________
#import "CustomTableCell.h"
@implementation CustomTableCell
{
@synthesize image;
- (id)initWithFrameCGRect)frame
{
if (self = [super initWithFrame:frame])
{
// Initialization code
}
return self;
}
- (void)drawRectCGRect)rect
{
// Drawing code
[self.image drawAtPoint:CGPointMake(0,0)];
}
- (void)dealloc
{
[super dealloc];
}
@end
___________________________________
inherited from UITableView and implements <UITableViewDelegate>
___________________________________
#import "CustomTableCell.h"
@implementation CustomTableView
- (UIImage*)getImageNSString *)imgUrl
{
id path = imgUrl;
NSURL *url = [NSURL URLWithStringath];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
return img;
}
- (id)initWithFrameCGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
cellViews = [[NSMutableArray alloc] init];
//CGRect rect = CGRectMake(0, 0, 50, 50);
CustomTableCell *eventsView = [[CustomTableCell alloc] initWithFrame:frame];
eventsView.image = [self getImage"pic1.png"];
[cellViews addObject:eventsView];
[eventsView release];
CustomTableCell *newsView = [[CustomTableCell alloc] initWithFrame:frame];
newsView.image = [self getImage"pic2.png"];
[cellViews addObject:newsView];
[newsView release];
}
return self;
}
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
NSLog(@"row #");
return [cellViews objectAtIndex:0];
}
- (void)dealloc {
[super dealloc];
}
@end
///////////////////////////////////////
I am trying to do a customised UITableview by drawing different images...
I could not really understand view controller based implementations, so i thought i would write mine. in fact i find it easier to write without using nib files
i wrote following code
unfortunately code never comes to cellForRowAtIndexPathNSIndexPath nor to drawrect of cellview ...
what am i doing wrong ?
////////////////////////////////////////
____________________________
inherited from TableViewCell
_____________________________
#import "CustomTableCell.h"
@implementation CustomTableCell
{
@synthesize image;
- (id)initWithFrameCGRect)frame
{
if (self = [super initWithFrame:frame])
{
// Initialization code
}
return self;
}
- (void)drawRectCGRect)rect
{
// Drawing code
[self.image drawAtPoint:CGPointMake(0,0)];
}
- (void)dealloc
{
[super dealloc];
}
@end
___________________________________
inherited from UITableView and implements <UITableViewDelegate>
___________________________________
#import "CustomTableCell.h"
@implementation CustomTableView
- (UIImage*)getImageNSString *)imgUrl
{
id path = imgUrl;
NSURL *url = [NSURL URLWithStringath];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
return img;
}
- (id)initWithFrameCGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
cellViews = [[NSMutableArray alloc] init];
//CGRect rect = CGRectMake(0, 0, 50, 50);
CustomTableCell *eventsView = [[CustomTableCell alloc] initWithFrame:frame];
eventsView.image = [self getImage"pic1.png"];
[cellViews addObject:eventsView];
[eventsView release];
CustomTableCell *newsView = [[CustomTableCell alloc] initWithFrame:frame];
newsView.image = [self getImage"pic2.png"];
[cellViews addObject:newsView];
[newsView release];
}
return self;
}
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
NSLog(@"row #");
return [cellViews objectAtIndex:0];
}
- (void)dealloc {
[super dealloc];
}
@end
///////////////////////////////////////