【发布时间】:2010-01-23 20:22:13
【问题描述】:
我使用了 TableView 并且还通过单击披露按钮使用了披露按钮,我得到了一个特定的图像。我希望当我按下披露按钮时,我必须通过执行方向来获得那个特定的图像,所以我该怎么做。请帮我。我是这种应用程序的新手。
【问题讨论】:
标签: iphone
我使用了 TableView 并且还通过单击披露按钮使用了披露按钮,我得到了一个特定的图像。我希望当我按下披露按钮时,我必须通过执行方向来获得那个特定的图像,所以我该怎么做。请帮我。我是这种应用程序的新手。
【问题讨论】:
标签: iphone
您需要手动转换表格。下面是一些创建 UITableView 并围绕其中心旋转的代码。
// this defines a constant PORTRAIT_FRAME, which is the frame of the iPhone screen
// minus the Status Bar. Equivalent to CGRectMake(0,20,320,460).
#define PORTRAIT_FRAME [[UIScreen mainScreen] applicationFrame]
// this defines a constant LANDSCAPE_FRAME, for orienting the table sideways
#define LANDSCAPE_FRAME CGRectMake(0,20,480,300)
// this function assumes you have a class variable called myTableView
// and it toggles the orientation of myTableView
- (void) rotateTable {
if (myTableView.transform == CGAffineTransformMakeRotation(0)) {
// rotate the image by 90 degrees
myTableView.transform = CGAffineTransformMakeRotation(M_PI/2);
myTableView.frame = LANDSCAPE_FRAME;
return;
}
// set the image to its original orientation
myTableView.transform = CGAffineTransformMakeRotation(0);
myTableView.frame = PORTRAIT_FRAME;
}
如果您想在单击按钮时触发此旋转,则声明一个 UIButton 并将此函数指定为操作。这是一个创建 UIButton 的函数。只需将 @"rotateImage" 传递给动作,将 self 传递给目标。
+ (UIButton*) getButtonAtPoint:(CGPoint)point
target:(id)target
action:(NSString*)action {
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[button addTarget:target
action:NSSelectorFromString(action)
forControlEvents:UIControlEventTouchUpInside];
return button;
}
【讨论】:
我认为您可能需要使用 UIApplication 的 setStatusBarOrientation:animated: 并手动旋转/调整顶级视图的大小。如果您使用 UIView 的动画块方法,那么您应该能够在动画块内执行此操作并提交它以获得基本相同的效果。不过我自己没试过。
【讨论】: