iphone应用开发教程(工具为Xcode6以上,使用storyboard)
2013-10-14 17:04
501 查看
https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphone101/Articles/05_ConfiguringView.html
重点是学习交互事件,控件如何与代码关联,主要是拖动控件到.h 或.m文件。
.h文件内如如下:
#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *userName;
- (IBAction)changeGreeting:(id)sender;
@end
.m文件内容如下:
The Implementation File: HelloWorldViewController.m
#import "HelloWorldViewController.h"
@implementation HelloWorldViewController
@synthesize textField=_textField;
@synthesize label=_label;
@synthesize userName=_userName;
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.textField) {
[theTextField resignFirstResponder];
}
return YES;
}
- (IBAction)changeGreeting:(id)sender {
self.userName = self.textField.text;
NSString *nameString = self.userName;
if ([nameString length] == 0) {
nameString = @"World";
}
NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!", nameString];
self.label.text = greeting;
}
@end
参考资料:http://blog.csdn.net/chinadeng/article/details/8667263 iPhone
开发之二---xcode 4.6 越狱 免证书 真机调试
http://blog.csdn.net/m_changgong?viewmode=contents iphone开发教程1、2、3
重点是学习交互事件,控件如何与代码关联,主要是拖动控件到.h 或.m文件。
.h文件内如如下:
#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *userName;
- (IBAction)changeGreeting:(id)sender;
@end
.m文件内容如下:
The Implementation File: HelloWorldViewController.m
#import "HelloWorldViewController.h"
@implementation HelloWorldViewController
@synthesize textField=_textField;
@synthesize label=_label;
@synthesize userName=_userName;
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.textField) {
[theTextField resignFirstResponder];
}
return YES;
}
- (IBAction)changeGreeting:(id)sender {
self.userName = self.textField.text;
NSString *nameString = self.userName;
if ([nameString length] == 0) {
nameString = @"World";
}
NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!", nameString];
self.label.text = greeting;
}
@end
参考资料:http://blog.csdn.net/chinadeng/article/details/8667263 iPhone
开发之二---xcode 4.6 越狱 免证书 真机调试
http://blog.csdn.net/m_changgong?viewmode=contents iphone开发教程1、2、3
相关文章推荐
- 在linux中用窗口参看文件时,如何显示当前的路径
- sql server竟然可以有办法不让事件探测器显示具体的sql
- js中常用的正则表达式
- TI8168嵌入式系统教学实验平台 & TI8168实验箱 & TI8168教学实验箱 & TI8168DSP实验箱
- 深圳市南山区新生儿入户流程
- 自学考试-数据结构
- Android 4学习(6):概述 - 深入了解Android Activity
- My97DatePicker 没有权限问题
- GridView的七种数据绑定列的类型
- Android 4学习(6):概述 - 深入了解Android Activity
- 自学考试-数据结构
- Ubuntu 13.04 VirtualBox在工作区中的切换
- VC串口通信PurgeComm
- 算法动态规划个人总结
- dwz dialog不出来的问题
- 大整数乘法的Karatsuba算法实现
- Capistrano集群部署CloudFoundry
- android_cpu/memory/进程/线程
- Climbing Stairs [LEETCODE]
- D3.js学习(一)