0
我有一個填充了行的表,每行包含圖像,標題和一個按鈕。
當用戶更改iPad按鈕的方向時,應根據iPad的方向重新排列。請教我如何重新排列uitableview單元格中的對象。
在此先感謝。在桌面視圖中重新排列iPad的不同方向的對象
我有一個填充了行的表,每行包含圖像,標題和一個按鈕。
當用戶更改iPad按鈕的方向時,應根據iPad的方向重新排列。請教我如何重新排列uitableview單元格中的對象。
在此先感謝。在桌面視圖中重新排列iPad的不同方向的對象
這將工作:
-(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.
}
}
創建recievedRotate:
- (void)receivedRotate:(NSNotification *)notification
{
[self checkOrientation];
}
在viewDidLoad中:
-(void)viewDidLoad
{
[self checkOrientation];
}
是的,你是對的,按鈕應重新排列根據iPad – rptwsthi 2011-06-17 06:32:01
@rptwsthi的方向,謝謝但如何重新排列。我已經完成了,但是在單元格中間顯示的舊按鈕和單元格末尾的新按鈕發生了什麼。 – 2011-06-17 06:33:32
您是否在每次更改方向時創建新按鈕 – rptwsthi 2011-06-17 06:45:51