这是我的.m我试图让一个UILabel到一个UIScrollView内滚动,但它不滚动
- (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;
我的标签是连接到View Controller,我的contentView连接到View Controller,我的summaryLabel连接到View Controller。我需要标签滚动,而不是。
哇我不能相信这是多么容易。谢谢。 –
您正在考虑使用UITextView的人们必须意识到这绝对是错误。如果你想滚动,以及设置字体大小/家庭,UITextView可能让你熬夜。 (特别是如果您以编程方式设置文本,而不是故事板)。 另请参阅http://stackoverflow.com/a/19168661/4493512 –