少尉

嗯。

 

2012年8月20日

动态添加view

摘要: 动态添加view博客分类:objective-c前面说的都是用的Interface Builder来编辑.xib文件来给窗口添加各种控件以及给控件绑定数据(IBOutlet)、关联事件响应函数(IBAction)。这章学习的是动态的添加view,不使用Interface Builder。这里用label和button示例:找到新建工程XXXViewController.m的-(void)loadView方法,去掉注释并添加如下代码- (void)loadView {//创建一个UIView 对象UIView *view =[[UIView alloc] initWithFrame:[UIScr 阅读全文

posted @ 2012-08-20 14:18 moonvan 阅读(1168) 评论(0) 推荐(0)

IOS学习之UISwitch控件两种使用方法和监听

摘要: IOS学习之UISwitch控件两种使用方法和监听分类:IOS开发入门2012-06-15 11:481363人阅读评论(0)收藏举报一、第一种创建UISwitch控件的方法,在代码中动态创建。1、打开Xcode 4.3.2, 新建项目Switch,选择Single View Application。2、打开ViewController.m文件在viewDidLoad方法里添加代码:[cpp]view plaincopy-(void)viewDidLoad{[superviewDidLoad];UISwitch*switchButton=[[UISwitchalloc]initWithFram 阅读全文

posted @ 2012-08-20 14:15 moonvan 阅读(4183) 评论(0) 推荐(0)

objective c 手动创建按钮并绑定事件处理程序

摘要: - (void)createButton { UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(100, 100, 100, 50); [myButton setTitle:@"click me!" forState:UIControlStateNormal]; SEL eventHandler = @selector(clickHandler); [myButton addTarget:self action:eventHa 阅读全文

posted @ 2012-08-20 14:10 moonvan 阅读(1054) 评论(0) 推荐(0)

导航