How to use scroll view on iPhone?

后端 未结 4 514
小蘑菇
小蘑菇 2021-01-12 01:19

I want to display a text with a lot of lines. I added a multiline-label to a scroll view, but it didn\'t show anything. Looks like this is not the correct way to use the scr

4条回答
  •  无人及你
    2021-01-12 02:01

    I used UIScrollView this way for an instructions pane in one of my applications. It worked but I was unhappy with the result. I then switched to using a UIWebView and have been much happier with the result. It handles sizing the scroll view automatically, I get all the formatting capabilities of HTML and I can have links that go to additional information (or external sites) with no more than adding another HTML file and maybe some delegate code. Here is the code I used (and I added the HTML file to my app as a resource):

    NSString *path = [[NSBundle mainBundle] pathForResource:@"instructions" ofType:@"html"];
    NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
    NSString *htmlString = [[NSString alloc] initWithData: [readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
    [self.instructionsView loadHTMLString:htmlString baseURL:nil];
    

提交回复
热议问题