I have a problem with iCarousel
view to resizing the item placed in carousel view during screen orientation changes.How can i fix this?
Here is my code
- ( void ) handleOrientation:(UIInterfaceOrientation )toInterfaceOrientation {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
orient = YES;
_deptCarousel.center = CGPointMake(390, 628);
}else {
orient = NO;
_deptCarousel.center = CGPointMake(512, 455);
}
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{
//create a numbered view
UIView *viewBG = nil;
viewBG = [[UIImageView alloc]initWithImage:[UIImage imageNamed:IS_IPAD?@"Scroll_Placeholder_ImageiPad.png":@"Carousel_Placeholder_Image.png"]];
if (IS_IPAD) {
if (orient) {
viewBG.frame = CGRectMake(0, 0, 420, 350);
}else{
viewBG.frame = CGRectMake(0, 0, 380, 280);
}
} else {
viewBG.frame = CGRectMake(0, 0, 210, 170);
}
}
I think you have checked your device orientation when the iCarousel
loads for the first time.You have to check and resize your Carousel
View whenever your orientation changes. So try to check it in the orientation delegate like below.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
UIInterfaceOrientation statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (IS_IPAD) {
if (orient) {
viewBG.frame = CGRectMake(0, 0, 420, 350);
}else{
viewBG.frame = CGRectMake(0, 0, 380, 280);
}
}
[_deptCarousel reloadData];
return YES;
}
I think it may help you. Please let me know if you have any queries in this.
Thank you.