Skip to content

Commit

Permalink
Finished DetailViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
myell0w committed May 24, 2011
1 parent 05d264a commit 72e7519
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
77 changes: 74 additions & 3 deletions Last.fm/Last/LFMDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ - (void)viewDidLoad {
self.titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, 10, 210, 20)] autorelease];
self.startDateLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, 31, 210, 20)] autorelease];
self.imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(230, 10, 80, 80)] autorelease];
self.mapView = [[[MKMapView alloc] initWithFrame:CGRectMake(10, 10, 300, 200)] autorelease];
self.mapView = [[[MKMapView alloc] initWithFrame:CGRectMake(10, 10, 300, 150)] autorelease];

UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease];
UIView *footerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 220)] autorelease];
UIView *footerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 170)] autorelease];

[headerView addSubview:self.titleLabel];
[headerView addSubview:self.startDateLabel];
Expand All @@ -77,7 +77,7 @@ - (void)viewDidLoad {
self.imageView.layer.borderColor = [UIColor whiteColor].CGColor;
self.imageView.layer.borderWidth = 2.f;

self.mapView.layer.cornerRadius = 4.f;
self.mapView.layer.cornerRadius = 12.f;
self.mapView.layer.borderColor = [UIColor whiteColor].CGColor;
self.mapView.layer.borderWidth = 2.f;

Expand Down Expand Up @@ -113,6 +113,77 @@ - (void)viewWillDisappear:(BOOL)animated {
[self.mapView removeAnnotation:self.event];
}

////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark UITableViewDataSource
////////////////////////////////////////////////////////////////////////

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if ([self.event.artists isKindOfClass:[NSArray class]]) {
return 1;
}

return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([self.event.artists isKindOfClass:[NSArray class]]) {
return self.event.artists.count;
}

return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
// create the parent view that will hold header Label
UIView* customView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.width, 25.0)] autorelease];

// create the button object
UILabel *header = [[[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.view.width-10, 25.)] autorelease];
header.font = [UIFont boldSystemFontOfSize:18];
header.textColor = [UIColor whiteColor];
header.shadowColor = [UIColor grayColor];
header.shadowOffset = CGSizeMake(0.0, 1.0);
header.opaque = NO;
header.backgroundColor = [UIColor clearColor];

header.text = [self tableView:tableView titleForHeaderInSection:section];
[customView addSubview:header];

return customView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 35.0;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Artists";
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"aMTTableViewCellID";

UITableViewCell *cell = nil;
NSString *artist = [self.event.artists objectAtIndex:indexPath.row];

// step 1: is there a dequeueable cell?
cell = [tableView dequeueReusableCellWithIdentifier:cellID];

// step 2: no? -> create new cell
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID] autorelease];
}

// step 3: set up cell values

// set title
cell.textLabel.text = artist;


return cell;
}

////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark MKMapViewDelegate
Expand Down
2 changes: 1 addition & 1 deletion Last.fm/Last/LFMEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ - (CLLocationCoordinate2D)coordinate {
////////////////////////////////////////////////////////////////////////

- (NSArray *)artists {
return [self.data objectForKey:@"artists"];
return [[self.data objectForKey:@"artists"] objectForKey:@"artist"];
}

- (NSArray *)images {
Expand Down

0 comments on commit 72e7519

Please sign in to comment.