I have a view controller that alternates 2 views on every touch. Each of the views overrides the drawRect function.
It works when the iPad is in portrait position but for landscape position, the view is shown in the right orientation only once. After that they always appear in portrait orientation.
What's wrong?
In ViewController:
- (void)loadView
{
v= [[View2 alloc] init];
self.view =v;
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
x++;
if (x%2==0)
{
v= [[View2 alloc] init];
}
else {
v=[[View3 alloc] init];
}
self.view = v;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}