problem in loading table when changing orientations in iphone sdk?
I have a customers list in a table view, my application supports orientation , I'm changing the frames of the buttons according to orientation, which I added to the table cell . But the changes are not occurring properly, the changes will be seen when I navigates to another view and I returns back. But not instantly.
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (UIInterfaceOrientationIsLandscape(interfaceOrie开发者_如何学JAVAntation)) {
isLandscape = YES;
myTableView.frame = CGRectMake(0, 0, 1024, 768);
labelTitle.frame = CGRectMake(500, 120, 300, 30);
accessoryBtnImageView.frame = CGRectMake(870, 46, 58, 58);
}
else
{
isLandscape = NO;
myTableView.frame = CGRectMake(0, 0, 768,1024);
labelTitle.frame = CGRectMake(350, 120, 300, 30);
accessoryBtnImageView.frame = CGRectMake(600, 66, 58, 58);
}
return YES;
}
I had used this coding in viewWillAppear
and
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
method also but still I'm getting problem, I think I'm doing some where wrong. please any one help me.
Thank You
Praveena
You should use the autoresizingMask
property on the views instead of resizing them manually.
Depending on how you set the resizing mask, you can make the views stick to one side, expand with the super view when the device rotates, etc.
The documentation describes how to do it in details.
精彩评论