您的位置:首页 > 其它

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: