Ir para conteúdo
Visualizar no app

Uma forma melhor de navegar. Saiba mais.

MM Fórum

Um app em tela cheia na sua Tela de Início com notificações push, avisos e mais.

Para instalar este app no iOS/iPadOS
  1. Toque no ícone de Compartilhamento no Safari
  2. Role o menu e toque em Adicionar à Tela de Início.
  3. Toque em Adicionar no canto superior direito.
Para instalar este app no Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Erro de comparação

Featured Replies

Postado

Oi de novo Galera.

Seguinte, tô aqui tentando resolver um outro problema em um app que tô fazendo pra iPhone, mas anda dando pau a 3x4.

O problema da vez é: eu tenho que coletar os dados de uma UITableView para exibir em um MKMapView, mas somente quando se seleciona uma opção ele exibe a anotação no mapa.

Eu tentei até alocar a classe mapa dentro da classe da tabela, mas ele me dá esse erro: "Object Cannot be set - either readonly property or no setter foundation".

Ai embaixo vai o código:

// Esse é o código de implementação da tabela. 

#import "ComoChegar.h"

@implementation ComoChegar

@synthesize places;
@synthesize texto;

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
    [super viewDidLoad];

	NSString *path = [[NSBundle mainBundle]pathForResource:@"lugares" ofType:@"plist"];

	places = [NSMutableArray arrayWithContentsOfFile:path];

	[places retain];

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

.
.
.

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [places count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
	lugar = [places objectAtIndex:indexPath.row];

	cell.textLabel.text = [lugar objectForKey:@"Local"];

    return cell;
}

.
.
.

#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
	Mapa *detailViewController = [[Mapa alloc] initWithNibName:@"Mapa" bundle:nil];

	detailViewController.locais = places;
	detailViewController.mapaZI = mapa;
	detailViewController.ZILeblon = ZIL;                // O erro é exibido aqui.
	detailViewController.ZICentro = ZIC;               // O erro é exibido também aqui.

	lugar = [places objectAtIndex:indexPath.row];

	if ([lugar objectForKey:@"Local"] == @"Centro") {
		[mapa addAnnotation:ZIC];
	} else if ([lugar objectForKey:@"Local"] == @"Leblon") {
		[mapa addAnnotation:ZIL];
	} 

	// Pass the selected object to the new view controller.
	[self.navigationController pushViewController:detailViewController animated:YES];
	[detailViewController release];
}

.
.
.

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


@end

// E esse o código do mapa

#import "Mapa.h"

@implementation Mapa

@synthesize mapaZI;
@synthesize places;
@synthesize locais;


-(MKAnnotationView *)mapview:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation {
	if ([annotation isKindOfClass:[MKUserLocation class]]) {
		return nil;
	}

	MKAnnotationView* anView = [theMapView dequeueReusableAnnotationViewWithIdentifier:@"MeuTipo"];

	if (anView = nil) {
		anView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MeuTipo"]autorelease];

		anView.image = [UIImage imageNamed:@"apple_touch_icon.png"];
	}
	else {
		anView.annotation = annotation;
	}
	return anView;
}

.
.
.

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

	// Definindo a anotação da ZI do centro no mapa...
	ZICentro = [[MKPointAnnotation alloc] init];
	ZICentro.coordinate = CLLocationCoordinate2DMake(-43.181371, -22.901634);
	ZICentro.title = @"ZONAInternet Centro";
	ZICentro.subtitle = @"Av. Pres. Vargas, 590, ";
	ZICentro.subtitle = @"sala 802, Centro-RJ.";

	// Definindo a anotação da ZI do Leblon no mapa...
	ZILeblon = [[MKPointAnnotation alloc] init];
	ZILeblon.coordinate = CLLocationCoordinate2DMake(-22.983024, -43.224528);
	ZILeblon.title = @"ZONAInternet Leblon";
	ZILeblon.subtitle = @"Rua General Urquiza, 163, ";
	ZILeblon.subtitle = @"Apto. 202, Leblon-RJ.";

	/*
	NSString *path= [[NSBundle mainBundle]pathForResource:@"lugares" ofType:@"plist"];
	locais = [NSMutableArray arrayWithContentsOfFile:path];
	[locais retain];

	if ([places objectForKey:@"Local"] == @"Centro") {
		[mapaZI addAnnotation:ZICentro];
	} else if ([places objectForKey:@"Local"] == @"Leblon") {
		[mapaZI addAnnotation:ZILeblon];
	} */
}

.
.
.

- (void)dealloc {
    [super dealloc];
	[ZICentro release];
	[ZILeblon release];
}

@end

Alguém pode me ajudar? só falta isso para completar o aplicativo e não estou conseguindo sair do lugar... :(

  • Respostas 1
  • Visualizações 763
  • Criado
  • Última resposta

Top Postadores Neste Tópico

Dias Populares

Postado
  • Autor

Tranquilo galera, dei jeito. Eu esquecí de colocar a property pro ZILeblon e pro ZICentro.

Participe do debate

Você pode postar agora e se registrar depois. Se você tem uma conta, entre agora para postar com ela.

Visitante
Responder este tópico…

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conta

Navegação

Buscar

Buscar

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.