| 

.NET C# Java Javascript Exception

3
hallo, ich würde gerne wie unten am Foto zu sehen ist mehrere images vor meinen Text setzen und einrichten, wie kann ich das machen ? bitte euch um hilfe Danke.

#define kSectionAddress 0
#define kSectionDescription 1
#define kSectionWebsite 2
#define kSectionPhoneNumber 3
#define kSectionDistance 4

@implementation RestaurantDetailsController RestaurantsController *restaurantsController;

@synthesize restaurant;
@synthesize mainTableView;
@synthesize footerView;
@synthesize callButton;
@synthesize viewWebsiteButton;
@synthesize directionsButton;



- (void)viewDidLoad{



UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
[button setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(infoButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

[button release];


if([self isiPhone] == NO){
self.callButton.alpha = 0;
}

if(restaurant.isFullyLoaded == NO){
[RestaurantRepository hydrateRestaurant:restaurant];
}

BOOL hasWebsite = self.restaurant.website.length > 2;
if(hasWebsite == NO){
self.viewWebsiteButton.alpha = 0;
}

BOOL hasLocation = [LocationRepository latitude] != 0 && [LocationRepository longitude] != 0;
if(hasLocation == NO){
self.directionsButton.alpha = 0;
}

if(hasWebsite && hasLocation == NO){
self.viewWebsiteButton.frame = self.directionsButton.frame;
}

[self.mainTableView setTableFooterView:self.footerView];
[self.mainTableView setSeparatorColor:[UIColor clearColor]];

[self createHeader];
[self createSectionsArray];

NSError *error;
NSString *url = [[NSString stringWithFormat:@"/restaurant_details/%d/%@", restaurant.restaurantId, restaurant.name] stringByReplacingOccurrencesOfString:@" " withString:@"_"];
NSLog(@"Track URL: %@", url);
if (![[GANTracker sharedTracker] trackPageview:url withError:&error]) {
NSLog(@"Error tracking page using google analytics: %@", error);
}
}

- (void)infoButtonClicked:(id)sender{
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"" style: UIBarButtonItemStyleBordered target: nil action: nil];
[[self navigationItem] setBackBarButtonItem: newBackButton];
[newBackButton release];

RestaurantsController *restaurantsController = [[RestaurantsController alloc] initWithNibName:@"Restaurants" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:restaurantsController animated:YES];
[restaurantsController release];
}



- (void)createSectionsArray{
sections = [[NSMutableArray alloc] init];
[sections addObject:[NSNumber numberWithInt:kSectionAddress]];
if(restaurant.description.length > 2)
[sections addObject:[NSNumber numberWithInt:kSectionDescription]];
if(restaurant.website.length > 2)
[sections addObject:[NSNumber numberWithInt:kSectionWebsite]];
if(restaurant.phoneNumber.length > 2)
[sections addObject:[NSNumber numberWithInt:kSectionPhoneNumber]];


// [sections addObject:[NSNumber numberWithInt:kSectionEmail]];

if([LocationRepository latitude] != 0 && [LocationRepository longitude] != 0){
[sections addObject:[NSNumber numberWithInt:kSectionDistance]];
}
}


- (NSString *)getTitleForSection:(NSInteger)section{
if(section == kSectionAddress)
return @"";
else if(section == kSectionDescription)
return @"";
else if(section == kSectionPhoneNumber)
return @"";
else if(section == kSectionWebsite)
return @"";



else if(section == kSectionDistance)
return @"";
else
return nil;

}


- (NSString *)getTextForSection:(NSInteger)section{
if(section == kSectionAddress)
return [NSString stringWithFormat:@"%@\n%@",restaurant.address, restaurant.suburb];
else if(section == kSectionDescription)
return restaurant.description;
else if(section == kSectionPhoneNumber)
return restaurant.phoneNumber;
else if(section == kSectionWebsite)
return restaurant.website;



else if(section == kSectionDistance)
return [NSString stringWithFormat:@"%1.2fkm", restaurant.distance];
else
return nil;
}


- (void)createHeader{
self.title = @"";
int titleFontSize = 20;

UILabel *titleLabel = [self.restaurant.name labelWithBoldSystemFontOfSize:titleFontSize];
titleLabel.text = self.restaurant.name;

titleLabel.textColor = [UIColor whiteColor];
titleLabel.frame = CGRectMake(titleLabel.frame.origin.x + 9, titleLabel.frame.origin.y + 20, titleLabel.frame.size.width, titleLabel.frame.size.height);

UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, titleLabel.frame.size.height + titleLabel.frame.origin.y + 12)];
[headerView addSubview:titleLabel];
self.mainTableView.tableHeaderView = headerView;

[titleLabel release];
[headerView release];
}



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [sections count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
NSInteger sectionIndex = [[sections objectAtIndex:section] intValue];
return [self getTitleForSection:sectionIndex];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSInteger sectionIndex = [[sections objectAtIndex:indexPath.section] intValue];
NSString *text = [self getTextForSection:sectionIndex];
CGFloat height = [text textHeightForSystemFontOfSize:10];
return height;
}



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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* cellIdentifier = @"DetailsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
////

////
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.backgroundColor = [UIColor clearColor];


NSInteger sectionIndex = [[sections objectAtIndex:indexPath.section] intValue];
UILabel *cellLabel = [[self getTextForSection:sectionIndex] labelWithSystemFontOfSize:14];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cellLabel.textColor = [UIColor whiteColor];



[cell.contentView addSubview:cellLabel];
[cellLabel release];

return cell;
}


- (IBAction)callButtonClicked:(id)sender{
[self callPhoneNumber];
}

- (BOOL)isiPhone{
NSString *deviceType = [UIDevice currentDevice].model;
return [deviceType isEqualToString:@"iPhone"]; //|| [deviceType isEqualToString:@"iPhone Simulator"];
}

- (void)callPhoneNumber{
NSString *phoneNumberUrl = [NSString stringWithFormat:@"tel://%@", self.restaurant.phoneNumber];
phoneNumberUrl = [phoneNumberUrl stringByReplacingOccurrencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumberUrl]];

NSError *error;
NSLog(@"Tracking event - Restaurant Details, Call, %@", self.restaurant.phoneNumber);
if (![[GANTracker sharedTracker] trackEvent:@"Restaurant Details" action:@"Call" label:self.restaurant.phoneNumber value:-1 withError:&error]) {
NSLog(@"Error tracking page using google analytics: %@", error);
}
}

- (IBAction)viewOnMapButtonClicked:(id)sender{
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"Details" style: UIBarButtonItemStyleBordered target: nil action: nil];
[[self navigationItem] setBackBarButtonItem: newBackButton];
[newBackButton release];

RestaurantMapController *restaurantMapController = [[RestaurantMapController alloc] initWithNibName:@"RestaurantMap" bundle:[NSBundle mainBundle]];
restaurantMapController.restaurant = self.restaurant;
[self.navigationController pushViewController:restaurantMapController animated:YES];
[restaurantMapController release];
}

//// action for email
/*
- (void)viewEmailButtonClicked:{
NSString *emailNumberUrl = [NSString stringWithFormat:@"mailto://%@", self.restaurant.emailNumber];
emailNumberUrl = [emailNumberUrl stringByReplacingOccurrencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailNumberUrl]];

NSError *error;
NSLog(@"Tracking event - Restaurant Details, Call, %@", self.restaurant.emailNumber);
if (![[GANTracker sharedTracker] trackEvent:@"Restaurant Details" action:@"Call" label:self.restaurant.emailNumber value:-1 withError:&error]) {
NSLog(@"Error tracking page using google analytics: %@", error);
}
}


- (IBAction)viewEmailButtonClicked:(id)sender{
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"Details" style: UIBarButtonItemStyleBordered target: nil action: nil];
[[self navigationItem] setBackBarButtonItem: newBackButton];
[newBackButton release];

RestaurantMapController *restaurantMapController = [[RestaurantMapController alloc] initWithNibName:@"RestaurantMap" bundle:[NSBundle mainBundle]];
restaurantMapController.restaurant = self.restaurant;
[self.navigationController pushViewController:restaurantMapController animated:YES];
[restaurantMapController release];
}

//// ende
*/
- (IBAction)viewWebsiteButtonClicked:(id)sender{
NSString *addressURL = [NSString stringWithString:self.restaurant.website];
addressURL = [addressURL stringByReplacingOccurrencesOfString:@" " withString:@"+"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:addressURL]];

NSError *error;
NSLog(@"Tracking event - Restaurant Details, View Website, %@", self.restaurant.website);
if (![[GANTracker sharedTracker] trackEvent:@"Restaurant Details" action:@"View Website" label:self.restaurant.website value:-1 withError:&error]) {
NSLog(@"Error tracking page using google analytics: %@", error);
}
}

- (IBAction)directionsButtonClicked:(id)sender{
NSString *destinationLatLong = [NSString stringWithFormat:@"%f,%f", self.restaurant.latitude, self.restaurant.longitude];
NSString *userLatLong = [NSString stringWithFormat:@"%f,%f", [LocationRepository latitude], [LocationRepository longitude]];
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%@&daddr=%@", userLatLong, destinationLatLong];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)dealloc {
[callButton release];
[footerView release];
[sections release];
[restaurant release];
[mainTableView release];
[super dealloc];
}


@end


derzeit :

so sollte es werden :

Danke
20.12.2011
snuffy 231 1 5
Bei mir sind die Bilder nicht zu sehen.. kannst du das nochmal prüfen?
puls200 20.12.2011
1 Antwort
0
Ohne das Wunschbild derzeit erkennen zu können ;-) kann ich schonmal soviel sagen: Am einfachsten ist es, eine neue UITableViewCell Klasse zu erzeugen, die von UITableViewCell ableitet und bei der Initialisierung im Layout mehrere Bilder anzeigt.
Hier findest du ein Tutorial. Darin geht es zwar um andere Controls, aber das Prinzip ist dasselbe. Interessant für dich das Listing für das Layout, wenn du die Seite etwa zur Hälfte hinunterscrollst. Statt UILabels füge einfach Bilder an der passenden Stelle hinzu. Das Aufwändigste ist dabei die Koordinatenberechnung. Hoffe, das setzt dich auf die richtige Spur.. :)
20.12.2011
puls200 3,8k 7

Stelle deine Iphone-Frage jetzt!