仅适用于iPhone的方向锁定

时间:2015-04-29 07:39:07

标签: ios iphone ipad screen-orientation uiscreen

我为UI应用设计了iOS wAny hRegular设置。

现在orientationiPad中正常工作。但是当应用程序在iPhone上运行时,orientation会显示一个空白屏幕。

是否有任何方法可以仅orientation iPhones锁定iPad并且describe('Login controller',function(){ beforeEach(module('app')); var httpBackend,ctrl, scope,userService; beforeEach(inject(function($controller, $rootScope,$httpBackend,$injector,_userService_) { scope = $rootScope.$new(); httpBackend = $injector.get('$httpBackend'); userService = _userService_; ctrl = $controller('LoginController', { $scope: scope }); })); it('should set authentication true', function() { scope.authenticateUser(); var username = 'test'; var password = '123456'; var requestToken = ""; httpBackend.whenGET('http://localhost:8080/services/request').respond(200,{ status : 0 }); httpBackend.expect('POST', 'http://localhost:8080/services/access').respond(200, { status:"success" }); var returnedPromise = userService.authenticateUser(username,password,requestToken); httpBackend.flush(); expect(scope.result).toEqual(0); httpBackend.verifyNoOutstandingExpectation(); httpBackend.verifyNoOutstandingRequest(); }); }); 可以使用方向?

3 个答案:

答案 0 :(得分:1)

您可以使用shouldAutorotatesupportedInterfaceOrientation UIViewController方法锁定iPhone上的旋转,但不能锁定iPad上的旋转。

只需返回适用于iPad的YESNO中适用于iPhone的shouldAutorotate,然后在supportedInterfaceOrientation中返回iPhone / iPad的允许定位。

答案 1 :(得分:0)

是@ david" mArm" Ansermot是对的,我刚刚添加了代码,以便快速捕捉: -

- (BOOL)shouldAutorotate {
         UIDevice* thisDevice = [UIDevice currentDevice];
        if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
          {
             return YES;
          }
        return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
    UIDevice* thisDevice = [UIDevice currentDevice];
    if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
          {
            return (UIInterfaceOrientationMaskAll);
           }
    return (UIInterfaceOrientationMaskPortrait);
}

答案 2 :(得分:0)

您可以从项目设置中执行此操作,请查看截图
1。 http://i.imgur.com/efGrNcL.png" iPhone设置"
2。 http://i.imgur.com/I25Z2cj.png" iPad设置"