开发者

Does UISearchBar works with UITextView?

I have been looking for a tutorial that integrates UISearchBar and UITextView and nothing is available. This makes me wonder, is this possible? I have wrote the following code:

- (IBAction)fileAction:(id)sender {

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"LICENSE" ofType:@"txt"];
    [textView setText:[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]];
}

Where I am reading the document named License.txt

I want to integrate a Search Bar to the View, but how do I make it work? How can I display the results of the search within the Text File? Is this possible? Can anyo开发者_运维知识库ne provide me with a sample code of this integration?


I'm not quite clear on what you want to do. If you want to highlight somehow the search text in a UITextView, you can't. It doesn't support formatted text. You have to use a WebView with HTML or use CoreText with an NSAttributedString.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜