iOS scrollview视窗滑动
来源:互联网 发布:淘宝客连接转换二维码 编辑:程序博客网 时间:2024/04/28 22:26
#import "ViewController.h"#import "testmenuEntity.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _scrollview.backgroundColor = [UIColor blueColor]; _scrollview2.backgroundColor = [UIColor yellowColor];// _scrollview.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }-(void) viewDidAppear:(BOOL)animated{ _scrollview.contentSize = CGSizeMake(190, 1200); _scrollview2.contentSize = CGSizeMake(150, 1000);}- (IBAction)addButton:(id)sender { // NSArray// NSMutableArray NSMutableArray *allmenu = [[NSMutableArray alloc] init]; int i = 0; for(i = 0; i < 10; i++) { testmenuEntity *e = [[testmenuEntity alloc] init]; e.mid = 10; e.mprice = 100.5; e.mname = [NSString stringWithFormat:@"%@", @"菜类型1" ]; [allmenu addObject:e]; testmenuEntity *e2 = [[testmenuEntity alloc] init]; e2.mid = 11; e2.mprice = 100.5; e2.mname = [NSString stringWithFormat:@"%@", @"菜类型2" ]; [allmenu addObject:e2]; } for(i = 0 ; i < [allmenu count]; i++) { testmenuEntity *tmpe = [allmenu objectAtIndex:i]; //动态添加一个按钮 CGRect frame = CGRectMake(0, 0+55*i, 300, 50); UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = frame; NSString *xxx = [NSString stringWithFormat:@"按钮:%d, %@", tmpe.mid, tmpe.mname]; [button setTitle:xxx forState: UIControlStateNormal]; button.backgroundColor = [UIColor redColor]; button.tag = tmpe.mid; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];// [self.view addSubview:button]; [_scrollview addSubview:button]; }}//这个是新按钮的响应函数-(IBAction) buttonClicked:(id)sender { NSLog(@"11111"); NSMutableArray *allmenu = [[NSMutableArray alloc] init]; int i = 0; for(i = 0; i < 2; i++) { testmenuEntity *e = [[testmenuEntity alloc] init]; e.mid = 10; e.mprice = 100.5; e.mname = [NSString stringWithFormat:@"%@", @"菜类型1" ]; [allmenu addObject:e]; testmenuEntity *e2 = [[testmenuEntity alloc] init]; e2.mid = 11; e2.mprice = 100.5; e2.mname = [NSString stringWithFormat:@"%@", @"菜类型2" ]; [allmenu addObject:e2]; } for(i = 0 ; i < [allmenu count]; i++) { testmenuEntity *tmpe = [allmenu objectAtIndex:i]; //动态添加一个按钮 CGRect frame = CGRectMake(0, 0+55*i, 300, 50); UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = frame; NSString *xxx = [NSString stringWithFormat:@"按钮:%d, %@", tmpe.mid, tmpe.mname]; [button setTitle:xxx forState: UIControlStateNormal]; button.backgroundColor = [UIColor redColor]; button.tag = tmpe.mid; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; // [self.view addSubview:button]; [_scrollview2 addSubview:button]; }}@end
0 0
- iOS scrollview视窗滑动
- iOS 降低scrollview滑动速度
- iOS实现左右循环滑动ScrollVIew
- iOS 自定义scrollView宽度,分页滑动
- android仿IOS,滑动隐藏底部ScrollView
- iOS自定义scrollview的滑动停止位置
- IOS ScrollView 子控件滑动手势冲突
- iOS实现左右循环滑动ScrollVIew
- iOS scrollView 左右滑动 内容错位
- iOS scrollView嵌套scrollView滑动到顶部须松手解决
- ios scrollView应对暴力滑动(快速滑动,暴力测试)
- ScrollView滑动
- IOS页面滑动Sample——ScrollView+PageControl
- IOS页面滑动Sample——ScrollView+PageControl
- IOS如何在StoryBoard中添加竖向滑动的ScrollView
- iOS 在ScrollView 上加 同向滑动手势
- iOS scrollview不能滑动的几个原因及解决方法
- iOS 中scrollView整个页面滑动自动居中
- Linux 的启动流程
- [Struts 2] 配置文件struts.xml的URL访问控制,及struts解析action方式
- 提高android应用的效率--主要讲解listview的优化
- 创建UIButton
- 【微信混淆】微信新的jar混淆无法分享问题
- iOS scrollview视窗滑动
- 嵌入式FTP服务器的移植与配置:VSFTPD-2.0.6移植
- 您的JAVA代码安全吗?(转)
- ctypes使用
- 21.PHP内核探索:理解Zend里的哈希表
- Excel 填充间格空白单元格与最上临近非空单元格值相同
- 十个最常用的StringUtils方法
- Node.js 的Process全局对象
- Memcache 相关介绍