我有一个由行填充的表,每行都包含图像、标题和按钮
当用户改变iPad的方向时,按钮应根据iPad的方向重新排列。请告诉我如何在uitableview单元格中重新排列对象
提前谢谢。
这将起作用:
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
-(void)viewWillDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}
现在实现以下方法:
-(void)checkOrientation
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft||orientation==UIDeviceOrientationLandscapeRight)
{
[tblView reloadData];
// Set x coorinate of views you want to change
}
else
{
[tblView reloadData];
// Set x coordinates of views to initial x xoordinates.
}
}
创建接收日期:
- (void)receivedRotate:(NSNotification *)notification
{
[self checkOrientation];
}
在viewDidLoad中:
-(void)viewDidLoad
{
[self checkOrientation];
}