여기 내 딜레마가 있습니다.이 점은 정말 이상하고 좀 우둔합니다. 앱이 있는데 가로 모드로 실행되며 내 휴대 전화에서 디버깅 할 때 가로 모드로 유지됩니다. 내 기본보기 컨트롤러에서 UIView에서 중심 값을 선택합니다.이 값은 화면 가운데에 항목을 넣을 때 필요하며 범용이므로 변수가 필요하고 iPhone 화면 크기로 설정되지 않아야합니다.가로 모드 UIView.center는 Potrait 모드 좌표를 제공합니다.
나는이 작업을 수행하고 view.center에 의해 반환 된 CGPoint에서 x와 y를 읽을 때 나는 y는, 중심 기능이 240
대리인이 내 응용 프로그램에서 하나 개의 ViewController입니다 X = 170 = 얻을 내가 중심으로 옮기고 싶은 대상 중 하나.
- (void) center
{
CGPoint center = ((UIViewController*)delegate).view.center;
CGSize size = self.frame.size;
double x = center.x - size.width/2 - location.x;
double y = center.y - size.height/2 - location.y;
[self _move:1.0 curve:UIViewAnimationCurveEaseInOut x:x y:y];
}
- (void)_move: (NSTimeInterval)duration
curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
self.transform = transform;
// Commit the changes
[UIView commitAnimations];
}
나에게 이것은별로 의미가 없습니다. 이 문제를 해결하는 방법에 대한 아이디어가있는 사람은 누구입니까?
가능한 중복 [UIView 너비와 높이 반전] (http://stackoverflow.com/questions/8141278/uiview-width-and-height-reversed) – jrturton