0
함수 매개 변수를 배열에 넣고 싶습니다.이 문제를 해결할 수는 없습니다. labelPoi는 imageLocationX, imageLocationY 및 name을 포함하는 객체 클래스입니다. 하나의 ViewController에서 발견 된 값을 다른 ViewController의 값에 할당하려고 시도하고 있습니다. Objective C 변수 할당이 작동하지 않습니다.
이
내 첫의 ViewControllerPointOfInterest.imageLocationX = (((([self getDegreesFromRadians:angle_horizontal]/[self getDegreesFromRadians:FOV_Horizontal]))) *1024);
PointOfInterest.imageLocationY = ((1-(([self getDegreesFromRadians:angle_to_bottom_of_view]/[self getDegreesFromRadians:FOV_Vertical])))*576);
PictureViewController *newlabel = [[PictureViewController alloc] display:PointOfInterest.imageLocationX andY:PointOfInterest.imageLocationY withName:PointOfInterest.name];
이고이 내 제의 ViewController에 (PictureViewController)
- (id)display:(double)imageXX andY:(double)imageYY withName:(NSString *)namee{
NSLog(@"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
NSLog(@"imageX: %f",imageXX);
NSLog(@"imageY: %f", imageYY);
NSLog(@"name: %@", namee);
labelPoi.imageLocationX = imageXX;
labelPoi.imageLocationY = imageYY;
labelPoi.name = name;
[transfer addObject:labelPoi];
NSLog(@"label.x: %f should be: %f", labelPoi.imageLocationX, imageXX);
NSLog(@"label.y: %f should be: %f", labelPoi.imageLocationY, imageYY);
NSLog(@"label.name: %@ should be: %@",labelPoi.name,namee);
return self;
}
그리고이 출력이다
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] %%%%%%%%%%%%%%%%%%%%%%%%
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] imageX: 224.485718
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] imageY: 116.353401
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] name: Beutel Student Health Center
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] label.x 0.000000
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] label.y 0.000000 should be 116.353401
2013-07-18 14:33:29.882 AR_UAV_App[10700:11303] label.name: (null) should be: Beutel Student Health Center#############################################################
이유가
NSLog(@"label.x: %f should be: %f", labelPoi.imageLocationX, imageXX);
출력이 0.00000입니까?
편집 : 이 당신은 할당하고 labelPOI
를 초기화해야 labelPoi
#import "Poi.h"
@implementation Poi
@synthesize longitude;
@synthesize latitude;
@synthesize name;
@synthesize x;
@synthesize y;
@synthesize distance;
@synthesize isVisibleToCamera;
-(id)initWithLatitude:(double)lat AtLongitude:(double)lon withName:(NSString *)name{
self = [super init];
if(self){
self.latitude = lat;
self.longitude = lon;
self.name = name;
}
return self;
}
'labelPoi'는'nil'입니까? 'alloc'와'init'로 먼저 객체를 생성해야합니다. – rmaddy
코드를 삭제 한 이유가 무엇인가요? 이것은 어떤 코드 없이는 전혀 답할 수 없습니다. –