Bas*_*025 0 uibutton uiscrollview uiimageview ios
我在xcode 4中制作一个ios应用程序,需要制作一个UIScrollView包含按钮和a的应用程序UIImageView.有谁知道如何编码?
(如果可能的话,我更愿意在故事板中这样做)
谢谢
在ViewDidLoad方法:
//添加ScrollView
UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,480)];
scrollview.showsVerticalScrollIndicator=YES;
scrollview.scrollEnabled=YES;
scrollview.userInteractionEnabled=YES;
[self.view addSubview:scrollview];
scrollview.contentSize = CGSizeMake(320,960);//You Can Edit this with your requirement
Run Code Online (Sandbox Code Playgroud)
//添加按钮
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[scrollview addSubview:button];
Run Code Online (Sandbox Code Playgroud)
//添加ImageView
UIImageView* iv =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourPhoto.png"]];
iv.frame=CGRectMake(0, 0, 40,60);
[scrollview addSubview:iv];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8109 次 |
| 最近记录: |