Here is a step to achieve this:
+ (KIFTestStep*) stepToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation {
NSString* orientation = UIInterfaceOrientationIsLandscape(toInterfaceOrientation) ? @"Landscape" : @"Portrait";
return [KIFTestStep stepWithDescription: [NSString stringWithFormat: @"Rotate to orientation %@", orientation]
executionBlock: ^KIFTestStepResult(KIFTestStep *step, NSError *__autoreleasing *error) {
if( [UIApplication sharedApplication].statusBarOrientation != toInterfaceOrientation ) {
UIDevice* device = [UIDevice currentDevice];
SEL message = NSSelectorFromString(@"setOrientation:");
if( [device respondsToSelector: message] ) {
NSMethodSignature* signature = [UIDevice instanceMethodSignatureForSelector: message];
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature];
[invocation setTarget: device];
[invocation setSelector: message];
[invocation setArgument: &toInterfaceOrientation atIndex: 2];
[invocation invoke];
}
}
return KIFTestStepResultSuccess;
}];
}
Note: Keep your device flat on a table or the accelerometer updates will rotate the view back.