0
我想把函數參數放到一個數組中,我無法弄清楚這是否適合我的生活。 labelPoi是一個包含imageLocationX,imageLocationY和名稱的對象類。我試圖將一個ViewController中的值分配給另一個ViewController中的值,但它不適合我。目標c變量賦值不起作用
這是我的第一個視圖控制器
PointOfInterest.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];
這是我的第二個視圖控制器(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?
編輯: 這是我的POI類,這是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
你爲什麼刪除代碼?如果沒有一些代碼,這是完全不能回答的。 –