iphone应用开发教程(工具为Xcode6以上,使用storyboard)

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值