我试图让 UILabel 在 UIScrollView 内滚动,但它不滚动 [英] I'm trying to get a UILabel to scroll inside of a UIScrollView but it doesnt scroll

查看:62
本文介绍了我试图让 UILabel 在 UIScrollView 内滚动,但它不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.scrollView addSubview:self.contentView];
    self.scrollView.contentSize = self.contentView.bounds.size;
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];

    NSMutableArray *arr = [[NSMutableArray alloc]init];
    arr = [Singleton getArray];

    NSString *str = [arr componentsJoinedByString:@"\n"];
    summaryLabel.text = str;
}

这是在我的 .h 中

@interface TotalViewController : UIViewController
{
    UIScrollView *scrollView;
    UIView *contentView;

}
@property (nonatomic, retain) IBOutlet UIScrollView * scrollView;
@property (nonatomic, retain) IBOutlet UIView       * contentView;
@property (nonatomic,strong) IBOutlet UILabel       * summaryLabel;

我的Label连接到View Controller,我的contentView连接到View Controller,我的summaryLabel连接到View Controller.我需要滚动标签,但它不是.

My Label is connected to the View Controller, my contentView is connected to the View Controller, and my summaryLabel is connected to the View Controller. I need the label to scroll and it is not.

推荐答案

一个非常简单的答案,如果你只想要一个可滚动的标签,将使用 UITextView 代替 (reference).禁用编辑,您将获得一个可滚动的标签.

A really simple answer, if you just want a single scrollable label, would be to use UITextView instead (reference). Disable editing, and you get a scrollable label.

(几乎逐字取自:如何添加滚动条函数到 UILabel)

这篇关于我试图让 UILabel 在 UIScrollView 内滚动,但它不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆