- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
}
Another Method:
Step1: Create 2 Views in Single Xib Page.
Step2: One is Portrait format
Another is landscape format
Step3: Add the coding into .h File
[super viewWillAppear:animated];
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
[Lable1 setFrame:CGRectMake(131, 31, 218, 30)];
[Lable2 setFrame:CGRectMake(131, 82, 218, 30)];
button1.frame = CGRectMake(173, 161, 110, 43);
[imgview setFrame:CGRectMake(0,225,488,46)];
}
}
Another Method:
Step1: Create 2 Views in Single Xib Page.
Step2: One is Portrait format
Another is landscape format
Step3: Add the coding into .h File
@property (nonatomic, retain) IBOutlet UIView *portraitView;
@property (nonatomic, retain) IBOutlet UIView *landscapeView;
Step4: Connect the outlets Portrait--> portraitView & landscape --> landscapeView.
Step5: Add the coding into .m File
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
self.view = self.landscapeView;
}
else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
self.view = self.portraitView;
}
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
self.view = self.landscapeView;
}
else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
self.view = self.portraitView;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
No comments:
Post a Comment