iOS 프로그래밍을 처음 사용하고보기 컨트롤러간에 데이터를 전달하는 데 문제가 있습니다.주석 제목을 다른보기 컨트롤러에 전달하는 방법
지도보기에서 주석을 지오 코딩하고 주소를 주석보기의 제목으로 설정하는보기 컨트롤러가 있습니다. 주석보기에는 레이블이있는 다른보기를 스택에 푸시하는 설명 선 단추가 있으며 지오 코딩 된 주소를 레이블로 표시하려고합니다.
#import <UIKit/UIKit.h>
@class MapPoint;
@interface PinViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate,UITextFieldDelegate>
{
__weak IBOutlet UILabel *addressLabel;
}
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (strong, nonatomic) MapPoint *pin;
-(void)takePicture:(id)sender;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
@end
#import "PinViewController.h"
#import "MapPoint.h"
@interface PinViewController()
@end
@implementation PinViewController
@synthesize imageView, pin;
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[addressLabel setText:[pin title]];
}
클래스를 MapPoint : 여기
-(void)press:(UILongPressGestureRecognizer *)recognizer
{
CGPoint touchPoint = [recognizer locationInView:worldView];
CLLocationCoordinate2D touchMapCoordinate = [worldView convertPoint:touchPoint toCoordinateFromView:worldView];
geocoder = [[CLGeocoder alloc]init];
CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
altitude:CLLocationDistanceMax
horizontalAccuracy:kCLLocationAccuracyBest
verticalAccuracy:kCLLocationAccuracyBest
timestamp:[NSDate date]];
[geocoder reverseGeocodeLocation:location
completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocoder:completionHandler: called");
if (error) {
NSLog(@"Geocoder failed with error: %@", error);
}
if (placemarks && placemarks.count > 0)
{
CLPlacemark *place = [placemarks objectAtIndex:0];
_address = [NSString stringWithFormat:@"%@ %@, %@ %@", [place subThoroughfare], [place thoroughfare], [place locality], [place administrativeArea]];
if (UIGestureRecognizerStateBegan == [recognizer state]) {
_addressPin = [[MapPoint alloc]initWithCoordinate:touchMapCoordinate
title:_address];
[worldView addAnnotation:_addressPin];
}
}
}];
}
내가 주소를 표시 할 뷰의 코드입니다
이 내가 핀을 놓는 위치입니다 : 여기에 몇 가지 코드입니다 title 속성과 subtitle 속성이 있습니다. PinViewController 스택의 맨 위로 밀어 때 레이블의 텍스트를 핀 제목으로 설정하려고하지만 레이블을 모든 텍스트를 표시하지 않습니다. 누군가 나를 도우 려하고 제가 누락 된 부분을 말해 줄 수 있습니까? 귀하의 도움을 크게 주시면 감사하겠습니다.
, 그 핀을 설정 선 탭 방식의 레이블 텍스트 및 탐색 스택에 밀어 넣습니다. – jrturton
핀 또는 공개 버튼을 클릭 한 후 라벨에 제목을 표시하려고 할 때 ...? – Rajneesh071
PinViewController의 레이블에서 공개 버튼을 누른 후 제목을 표시하려고합니다. –