0

如何证明文本的合理性UITextView 我这样尝试,但这段代码没有给出任何输出。

[web loadHTMLString:[NSString stringWithFormat:
     @"<html><body><p align=\"justify\"> %@ </p> </body></html>",
     [dict1 objectForKey:@"services_description"]] baseURL:nil];
4

4 回答 4

2
textView.textAlignment = NSTextAlignmentJustified;

这仅适用于 iOS 6 及更高版本

于 2014-04-11T13:09:33.633 回答
0

您可以使用propertext allignment 创建一个HTML 页面,然后在Web 视图中加载本地HTML 页面。

  webView = [UIWebView alloc] init];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] 
                                pathForResource:@"test" ofType:@"html"]isDirectory:NO]]];
于 2012-09-21T06:18:13.647 回答
0

我建议您使用 WebView,因为文本的对齐对齐方式只有 center、left 和 right by UITextView

如果你想使用UIWebView然后设置

className.h

@interface className : UIViewController {
    IBOutlet UIWebView *webviewName;
}
@property (nonatomic, retain) UIWebView *webviewName;  

类名.m

[webviewName loadHTMLString:[NSString stringWithFormat:@"<div align='justify'>%@<div>",TEXT_set] baseURL:nil];
于 2012-09-21T05:50:46.277 回答
0

您可以通过从实用程序中选择对齐方式来证明 UITextView 中的文本

于 2012-09-21T05:54:59.037 回答