Objective c 如何在ScrollView中添加标签
我是Xcode 5和Objective C的新手。我想开发文字处理应用程序。不过,我还是不知道如何使用Xcode来实现它 如何在Objective c 如何在ScrollView中添加标签,objective-c,uiscrollview,label,uilabel,xcode5,Objective C,Uiscrollview,Label,Uilabel,Xcode5,我是Xcode 5和Objective C的新手。我想开发文字处理应用程序。不过,我还是不知道如何使用Xcode来实现它 如何在滚动视图中添加标签,从左向右滑动方向:从左到预览,从右到下一个单词 如何向Xcode中的UIlabel添加100个单词 例如,右击下一个单词“苹果”,然后再右击下一个单词“香蕉”;向左滑动预览:“Apple”。这是UIScrollView分页的行为。在这里你可以找到 如何将UILabel(通常是UIView上的任何实例)添加到UIScrollView UIScrollV
滚动视图中添加标签,从左向右滑动方向:从左到预览,从右到下一个单词
如何向Xcode中的UIlabel
添加100个单词
例如,右击下一个单词“苹果”,然后再右击下一个单词“香蕉”;向左滑动预览:“Apple”。这是UIScrollView分页的行为。在这里你可以找到
如何将UILabel(通常是UIView上的任何实例)添加到UIScrollView
UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
scrollView.pagingEnabled = YES; // replace default scroll with paging
for ( int i = 0; i < mWordsCount; i++ )
{
UILabel* textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width * i, self.view.frame.size.height)];
textLabel.text = @"currnet word"; // wordsArray[i]; or [wordsArray objectAtIndex:i];
[scrollView addSubview:textLabel];
// Uncomment if you don't use ARC
//[textLabel release];
}
UIScrollView*scrollView=[[UIScrollView alloc]initWithFrame:self.view.bounds];
scrollView.PaginEnabled=是;//将默认滚动替换为分页
对于(int i=0;i
//scrollVC.h
#import <UIKit/UIKit.h>
@interface scrollVC : UIViewController
@property (weak, nonatomic) IBOutlet UIScrollView *mainScroll;
@end
请添加您尝试过的代码。下面是我尝试过的代码。
#import "scrollVC.h"
@interface scrollVC ()
@end
@implementation scrollVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.mainScroll setContentSize:CGSizeMake(960, 995)];
[self.mainScroll setPagingEnabled:YES];
UILabel *testLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(350, 100, 100, 44)];
[testLabel1 setText:@"testLabel1"];
[testLabel1 setBackgroundColor:[UIColor redColor]];
[self.mainScroll addSubview:testLabel1];
UILabel *testLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(660, 100, 100, 44)];
[testLabel2 setText:@"testLabel2"];
[testLabel2 setBackgroundColor:[UIColor redColor]];
[self.mainScroll addSubview:testLabel2];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end