English 中文(简体)
计算《UITextView》高度,体积为WithFont:经过培训的ToSize:lineBreakModetn t 似乎回报正确的结果
原标题:Calculate the height of a UITextView s text with sizeWithFont:constrainedToSize:lineBreakMode doesn t seem to return correct results

我试图计算受UITextView限制的案文的高度,但似乎没有回过正确结果。

我的法典如下:

- (void)textViewDidChange:(UITextView *)aTextView {
    CGSize textSize = [aTextView.text sizeWithFont:aTextView.font constrainedToSize:aTextView.frame.size lineBreakMode:UILineBreakModeWordWrap];
    counter.text = [NSString stringWithFormat:@"%f", textSize.height];
}

页: 1 样本项目和说明问题的短屏幕(418 KB)

总而言之,问题是,当我一行结尾处用一个很长的字句时,这个词被移至下行,但是,如果发生的话,则该星体的高度就会受到正确的调整。

感谢任何帮助。

Best,
Thomas.

P.S.:与Peit SDK 3.1.3有关。

问题回答

问题是,UIText Field在其实际提取和总结案文的地区有小差。 就我所知,没有方案途径来达到这一规模,但仅仅从面积中减去6个或6个,就应当使其行为适当。





相关问题
How do you create UIBarButtonItems with a radio interface?

I have a UIToolbar that needs three buttons in a radio style, meaning that of the three, only one button can be pushed at a time. The documentation makes reference to the possibility of setting up ...

iPhone settings bundle

I want to allow the user to enter a valid date using the iPhone’s settings application. I have experimented with many of the PreferenceSpecifiers data node types including date. I have two issues: ...

Circular #import/@class problem in ObjectiveC

I m going to use an example to properly illustrate my confusion. I can t quite wrap my head around this. In Cocoa touch, we have UIViewController and its subclass, UINavigationController. Now, UIVC ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Cocoa-Touch: issue looping MPMoviePlayerController

I have an app which has to load some data at startup, so I want to display a splash-screen animation. I m using the MPMoviePlayerController to play a m4v file. The movie has it s background set to [...

Iphone sequential animation with setAnimationDelay

I m trying to chain animation events. The application I m coding for work has a multiple choice quiz. First you pick your multiple choice answer. The quiz view fades away. Then a label ("correct" or "...

热门标签