久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何通過從 Swift 中的 UIScrollView 子類化來制作垂

How to make a vertical UITextView by subclassing it from UIScrollView in Swift?(如何通過從 Swift 中的 UIScrollView 子類化來制作垂直 UITextView?)
本文介紹了如何通過從 Swift 中的 UIScrollView 子類化來制作垂直 UITextView?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我是 iOS 開發的新手,但為了開始使用垂直蒙古文腳本制作最基本的應用程序,我需要一個垂直的 UITextView.我還沒有找到任何其他蒙古應用程序開發人員共享他們的代碼,所以我正在嘗試自己制作.蒙古語從上到下書寫,從左到右換行,如下圖所示:

I'm new to iOS development, but in order start making even the most rudimentary apps using the vertical Mongolian script, I need to have a vertical UITextView. I haven't found any other Mongolian app developers sharing their code so I am trying to make it myself. Mongolian is written from top to bottom and lines wrap from left to right as is illustrated in the following graphic:

滾動應該是水平的(從左到右).

Scrolling should be horizontal (left to right).

在 previous question 我提出了一個鏡像字體以及 UITextView 的旋轉和鏡像的組合(因為這是我在 Android 中所做的).但是,在閱讀 this answer 并進一步研究 iOS 的做事方式(如使用 TextKit),我想它可能最好從頭開始創建像 UIVerticalTextView 這樣的東西,而不是弄亂普通的 UITextView.因為我看到 UITextView 繼承自 UIScrollView,我假設我應該繼承 UIScrollView 來制作 UIVerticalTextView.

In a previous question I proposed a combination of a mirrored font and a rotation and mirroring of the UITextView (because that is what I had done in Android). However, after reading this answer and doing further research into the iOS way of doing things (like using TextKit), I'm thinking it may be better to just create something like UIVerticalTextView from scratch rather than messing with the normal UITextView. And since I see that UITextView inheirits from UIScrollView, I assume I should subclass UIScrollView to make the UIVerticalTextView.

我上面提到的答案是 UIView 的子類,但我在獲取時遇到了很多麻煩滾動上班.這是我想繼承 UIScrollView 的另一個原因.此外,當方向發生變化時,該解決方案不會重新排列每行中的單詞.

The answer I mentioned above subclassed UIView but I was having a lot of trouble getting scrolling to work. This is another reason I want to subclass UIScrollView. Also that solution did not relayout the words in each line when there was an orientation change.

我收集了以下部分,但我不知道如何將它們組合在一起:

I've gathered the following pieces but I'm not sure how to put them together:

  • NSTextStorage - 應該有這沒什么不同.它只會存儲蒙古語 Unicode 文本和任何樣式信息.
  • NSTextContainer - 高度并且需要切換寬度以給出垂直文本容器的大小.(無論如何,我認為是的.除非這可以在其他地方完成.)
  • NSLayoutManager - 什么都做特別需要在這里完成還是由 UIVerticalTextView 處理?
  • UIVerticalTextView - 這將是 UIScrollView 的子類,但需要添加和/或覆蓋哪些方法?

  • NSTextStorage - There shouldn't be anything different with this. It will just store the Mongolian Unicode text and any styling information.
  • NSTextContainer - The height and the width need to be switched to give the vertical text container size. (I think so, anyway. Unless this can be done somewhere else.)
  • NSLayoutManager - Does anything special need to be done here or is that taken care of by the UIVerticalTextView?
  • UIVerticalTextView - This will be a subclass of UIScrollView but what are the methods that need to be added and/or overridden?

class UIVerticalTextView: UIScrollView {

    // Which properties to include?
    //     - TextStorage
    //     - TextContainer
    //     - LayoutManager

    // which methods to override?

    // which methods to add to give minimal functionality like UITextView?
    //     - init
    //     = text
}

這些問題試圖將問題分解成更小的部分:

These questions are attempts to break the problem down into smaller pieces:

  • 如何從頭開始制作 UITextView?
  • 如何在 Swift 中使用字符串初始化 NSTextStorage

并嘗試不同的方法:

  • 旋轉視圖是否與自動布局兼容?
  • 在 layoutSubviews 中旋轉視圖這實際上現在有一個可行的解決方案.但是,它基本上涉及將三個視圖堆疊在一起.我仍然希望創建一個使用 TextKit 的自定義 UIScrollView 子類,就像我在當前問題中提出的那樣.
  • Are rotated Views compatible with Auto Layout?
  • Rotating a view in layoutSubviews This actually has a working solution now. However, it basically involves stacking three views on top of each other. I would still prefer to make a custom UIScrollView subclass that uses TextKit as I have presented in my current question.

推薦答案

如果你有一個顯示文本的字體,最簡單的方法是使用普通的 UITextView:

If you have a font that displays your text the easiest way would be to use the normal UITextView:

UITextView *textView = [[UITextView] alloc] init];

textView.transform = CGAffineTransformMakeRotation(-M_PI/2);

textView.text = @"YOUR TEXT HERE";

[textView setBaseWritingDirection:UITextWritingDirectionRightToLeft forRange:[textView textRangeFromPosition:[textView beginningOfDocument] toPosition:[textView endOfDocument]]];

textView 現在將向右滾動而不是向下滾動,我認為這應該發生在蒙古語中?

The textView will now scroll to the right not down, I assume that is supposed to happen for mongolian?

這篇關于如何通過從 Swift 中的 UIScrollView 子類化來制作垂直 UITextView?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 羞羞的视频网站 | 熟女毛片 | 国产精品久久久久久久久久久久冷 | 欧美综合在线视频 | 国产女人叫床高潮大片免费 | 小草久久久久久久久爱六 | 亚洲欧美日韩在线 | 成人水多啪啪片 | 久久三区| av一区二区三区四区 | 久久久精品国产 | 国产成人精品免费视频大全最热 | 日韩成人影院 | 二区亚洲| 337p日本欧洲亚洲大胆鲁鲁 | 国产日韩一区二区三免费高清 | 国产欧美久久精品 | 国产在线精品免费 | 国产成人精品一区二 | 日本一区二区三区四区 | 毛片.com | 成年视频在线观看福利资源 | 亚洲精品久久久一区二区三区 | 欧美黑人激情 | 亚洲一区二区三区在线播放 | 国产精品我不卡 | 在线免费观看日本视频 | 午夜成人在线视频 | 在线观看免费av网 | 中文字幕一区二区三区不卡 | 亚洲精品字幕 | 免费看黄色小视频 | 亚洲国产精品视频 | 久久久99精品免费观看 | 久久激情五月丁香伊人 | www日韩高清 | 91视频正在播放 | 久久9视频 | 情侣黄网站免费看 | 久久久久国产精品 | 亚洲一区二区三区四区五区午夜 |