这是我的.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/