简体   繁体   English

Swift如何在纵向设备方向内将视图转换为横向? 有可能的?

[英]Swift How can i convert view to landscape , inside portrait device orientation? It is possible?

How can i convert view to landscape inside portrait device orientation 如何在人像设备方向内将视图转换为横向

My View controller Code. 我的View控制器代码。

import UIKit

class SampleViewController: UIViewController {


    var commingtextview:String = ""


    @IBOutlet weak var textview: UITextView!


    override func viewDidLoad() {
        super.viewDidLoad()

        navigationController!.navigationBar.barTintColor = UIColorFromRGBs(0x000000)
        navigationController!.navigationBar.tintColor = UIColor.whiteColor();


       textview.text = self.commingtextview

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

Important ! My project portrait must be portrait i want to change only this view orientation to landscape. 我的项目肖像必须是肖像,我只想将此视图方向更改为横向。

Also my project orientation 还有我的项目方向

[x] Portrait [x]肖像

[ ] Upside Down [ ] 上下翻转

[ ] Landscape Left []风景左

[ ] Landscape Right []景观权

Use :- 采用 :-

override func viewWillAppear(animated: Bool) {

    super.viewWillAppear(animated)


    self.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
  // Set whatever frame you want
  // self.view.frame = CGRectMake(xOrigin,yOrigin,Width,Height)


}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果应用程序设备的方向是纵向的,那么如何仅在iOS中为一个视图构建者设置强制横向,Swift 2.3 - if app device orientation is portrait how to set force landscape only for one view constroller in ios, swift 2.3 如何从具有横向方向的视图控制器中以纵向显示新的纵向视图控制器? - How can I modally display a new view controller with a portrait orientation, from a view controller that has a landscape orientation? 当设备的方向为横向时,如何在应用程序中的任何位置加载特定视图,并在纵向时切换为横向视图? - How to load a particular view when device's orientation is landscape any where in the app and switch to the lat view when portrait? 如何允许特定的视图控制器同时支持横向和纵向 - How to allow a particular view controller to support for both landscape and portrait orientation IOS设备方向卡在纵向模式下,没有横向 - IOS Device Orientation Stuck at Portrait mode, no Landscape 横向设备中的纵向视图 - Portrait view in a landscape oriented device UIDeviceOrientation 在 Swift 中以纵向模式提供横向方向 - UIDeviceOrientation giving landscape orientation in Portrait mode in Swift 当用户在 swift 中将屏幕从纵向更改为横向时,如何使滚动视图内的 UIView 适应屏幕方向 - How to make UIView which is inside scrollview adapt to screen orientation when user changes screen from portrait to landscape in swift 如何找出纵向或横向的屏幕方向? - How do I find out the screen orientation, in portrait or landscape? 为什么纵向内容以横向显示? - Why portrait content displayed inside the landscape orientation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM