objective c - iPhone UIView center property returning bad value -
i'm working view-based application compiling iphoneos 4.0 simulator (debug), xcode 3.2.3.
i've got uiimageview, imgview, center want coordinates of. obtain them this:
cgpoint imgviewcoords=[imgview center];
this doesn't produce compile-time errors, when nslog coordinates this:
nslog(@"x: %i, y:%i", imgviewcoords.x, imgviewcoords.y);
i output:
x: 0, y:108762
it's showing 0 imgview's x coordinate (which know isn't right, because imgview near top-middle of screen on interface builder) , giant impossible number way past boundaries of iphone's screen y coordinate (the y coordinate in output above may not correct, it's giant number that). same exact output each time. imgview linked file's owner outlet, , can change image using
[imgview setimage:[uiimage imagenamed:@"./blahblah.png"]];
i can't seem center coordinates. i've tried
cgpoint viewcoords=[[imgview frame] origin];
and gives me same erroneous coordinates in imgviewcoords described above. happens every control have in app's main uiview, except y coordinate differs little bit each control. doing wrong?
@vladimir : suggestion change nslog format specifiers. however, don't think it's output problem. think it's [imgview center] call isn't working. i'm using cgpoint that's returned [imgview center] set center of uiimageview, , uiimageview moves top-left of screen instead of moving center of imgview. i'm guessing it's [imgview center] call returning bad set of coordinates.
%i format specifier expects integer value , cgpoint components have cgfloat type, try use correct specifier (%f) - may correct output:
nslog(@"x: %f, y:%f", imgviewcoords.x, imgviewcoords.y);
Comments
Post a Comment