ios - 我试图让 UILabel 在 UIScrollView 内部滚动,但它不滚动

标签 ios singleton nsmutablearray

这是我的.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 。我需要滚动标签,但事实并非如此。

最佳答案

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

(几乎一字不差地摘自:how to add a scroll function to a UILabel)

关于ios - 我试图让 UILabel 在 UIScrollView 内部滚动,但它不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11302357/

相关文章:

ios - 在主 Storyboard顶部呈现锁定屏幕

ios - Facebook iOS SDK - 如何为 Xcode 4.3 构建静态库?

javascript - 在 CoffeeScript 中为我的单例类定义属性 getter

java - java中的枚举如何线程安全?

ios - 保存可变图像数组并加载它们

ios - UITextview 在文本中心对齐中编写,快速

ios - SKShapeNode 检测两条线的交点

iphone - UIViewControllerHierarchyInconsistency 异常时

ios - 我们应该为一个单例类创建多个对象吗?这适合单例设计模式吗

iphone - 如何搜索 NSMutableArray