iOS study Day22-storyboard 和xib的混搭
来源:互联网 发布:网络监控摄像头ip地址 编辑:程序博客网 时间:2024/05/13 20:54
#define LINEHEIGHT 44.0#define TEXTTAG 10#import "WViewController.h"@implementation WViewController-(IBAction)deleteLast{ UIView* lastview = [self.view.subviews lastObject]; CGRect rect = lastview.frame; rect.origin.x = self.view.frame.size.width; [UIView animateWithDuration:0.5f animations:^{ [lastview setFrame:rect]; } completion:^(BOOL finished) { [lastview removeFromSuperview]; _removeIt.enabled = [self.view.subviews count] > 3; }];}- (IBAction)newtext{ // 新建littlesub.xib文件,设置尺寸为null ,添加组件,Label.tag = 10 // 调用bundle 的loadnib方法得到xib文件 UIView* littleSub = [[NSBundle mainBundle] loadNibNamed:@"Littlesub" owner:self options:nil][0]; // 此处计算出现 xib文件的位置 UIView* lastview = [self.view.subviews lastObject]; CGFloat newy = ([self.view.subviews count] == 3)?( 40 ):(lastview.frame.origin.y + LINEHEIGHT +1 ); CGRect frame2 = CGRectMake(0, newy, self.view.frame.size.width, LINEHEIGHT); // viewwithtag方法得到xib文件中的按钮属性 UIButton* button = (UIButton *)[littleSub viewWithTag:5]; // 代码对其做关联,设置方法littleClick ,并传入自身对象 [button addTarget:self action:@selector(littleClick:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:littleSub]; UILabel* label = (UILabel*)[littleSub viewWithTag:10]; label.text = [NSString stringWithFormat:@"%d is me", [self.view.subviews count]]; CGRect frame1 = frame2; frame1.origin.x = self.view.frame.size.width; [littleSub setFrame:frame1]; // 动画效果 [UIView beginAnimations:nil context:nil]; [littleSub setFrame:frame2]; [UIView commitAnimations];}// 按钮得到子对象tag= 10的值- (IBAction)littleClick:(UIButton*)sender{ UILabel* label = (UILabel*)[sender.superview viewWithTag:10]; NSLog(@" %@ at view", label.text); }@end
0 0
- iOS study Day22-storyboard 和xib的混搭
- ios-xib和storyboard
- IOS, xib和storyboard的混用
- IOS, xib和storyboard的混用
- IOS, xib和storyboard的混用
- IOS中storyboard和xib的区别
- IOS开发:xib和storyboard的混用
- iOS Xib 和 storyboard 相关
- 代码手写UI,xib和StoryBoard间的博弈(IOS)
- Xib和storyboard的比较
- Xib和StoryBoard的区别
- Xib和StoryBoard的比较
- xib和storyboard的使用
- iOS学习笔记5 - xib和Storyboard
- iOS XIB以及Storyboard的部分使用方法
- storyboard 和xib的本地化的应用
- storyboard和xib不同的人生道路
- Storyboard和Xib的混合用法
- mac 隐藏文件快捷键创建过程(图文并茂)
- DirectX与VS2010的配置
- 复数模板
- JQuery的Ajax跨域请求的解决方案
- 网站二级域名到底好不好
- iOS study Day22-storyboard 和xib的混搭
- 自增运算符重载
- Unity3D的断点调试功能
- NYOJ42-一笔画问题
- rest-work-eat-study-rest-work-eat or rest-rest-work-work-eat-eat..
- More about Vector
- 回文字符串的判定------非递归与递归实现(未完)
- 在UI中调用套打
- eas 关于ID