- 浏览: 2564498 次
- 性别:
- 来自: 成都
-
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
IPhone Development Tips(2)First Simple Sample
2. Build Action for Pages
Add action for the button
select 'MainStoryboard.storyboard', change to 'Assistant Editor' at the right top.
select the file hello3ViewController.h in Assistant
select the button and push 'ctrl' on our keyboard, we drag our mouse between the
@interface hello3ViewController : UIViewController
@end
We get a window. We will configure some items as following:
Connection ----> Action
Name ----> greeting
Type --> id
Event --> Touch Up Inside
Arguments ---> Sender
click 'connect', the xcode will add interface in .h file, and implementation in .m file.
Create Outlets for the Text Field and the Label
When you create an outlet connection in Xcode, the connection is archived in the storyboard file and restored when the app runs. The restored connection allows the two objects to communicate with each other at runtime.
create the outlet to textField, the related window shows these items:
Connection ---> Outlet
Name ----> textName
Type ----> UITextField
Storage ---> Weak ------------>> Click 'Connect' after enter all these values.
add method in .m file:
- (void) viewDidUnload
{
[self setTextName:nil];
[super viewDidUnload];
self.textname = nil;
}
Add outlet to label. And we can see the connections information after we click the 'connection inspector' button at the right top.
Make the Text Field's Delegate Connection
push ctrl and select text field and drag to the right yellow button with name 'Hello3 View Controller'.
release mouse and select delegate.
Implementing the View Controller
Add a Property for the User's Name
In the file hello3ViewController.h
@interface hello3ViewController:
UIViewController{
NSString *userName;
}
...
@property (nonatomic,copy) NSString *userName;
@end
In the file hello3ViewController.m
@implementation hello3ViewController
@synthesize textName = _textName;
@synthesize labelGreeting = _labelGreeting;
@synthesize userName = _userName;
...
- (IBAction)greeting:(id)sender {
self.userName = self.textName.text;
NSString *nameString = self.userName;
if([nameString lenght] == 0){
nameString = @"World";
}
NSString *greeting = [[NSString alloc]
initWithFormat:@"hello, %@!",nameString];
self.labelGreeting.text = greeting;
}
Configure the View Controller as the Text Field's Delegate
In an iOS app, the keyboard is shown automatically when an element that allows text entry becomes the first responder, it is dismissed automatically when the element loses first responder status.
select file hello3ViewController.m file
...snip...
-(BOOL)textFieldShouldReturn:(UITextField *)theTextField{
if(theTextField == self.textName){
[theTextField resignFirstResponder];
}
return YES;
}
...
@end
select the .h file and add some to the @interface line:
@interface hello3ViewController : UIViewController <UITextFieldDelegate>{
...snip...
error message:
unrecognized selector sent to instance ....
solution:
I link the method input to textfield, but I did not delete that.
references:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iPhone101/Articles/05_ConfiguringView.html
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/ios_development_workflow/000-Introduction/introduction.html
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/Introduction/Introduction.html
http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/_index.html
2. Build Action for Pages
Add action for the button
select 'MainStoryboard.storyboard', change to 'Assistant Editor' at the right top.
select the file hello3ViewController.h in Assistant
select the button and push 'ctrl' on our keyboard, we drag our mouse between the
@interface hello3ViewController : UIViewController
@end
We get a window. We will configure some items as following:
Connection ----> Action
Name ----> greeting
Type --> id
Event --> Touch Up Inside
Arguments ---> Sender
click 'connect', the xcode will add interface in .h file, and implementation in .m file.
Create Outlets for the Text Field and the Label
When you create an outlet connection in Xcode, the connection is archived in the storyboard file and restored when the app runs. The restored connection allows the two objects to communicate with each other at runtime.
create the outlet to textField, the related window shows these items:
Connection ---> Outlet
Name ----> textName
Type ----> UITextField
Storage ---> Weak ------------>> Click 'Connect' after enter all these values.
add method in .m file:
- (void) viewDidUnload
{
[self setTextName:nil];
[super viewDidUnload];
self.textname = nil;
}
Add outlet to label. And we can see the connections information after we click the 'connection inspector' button at the right top.
Make the Text Field's Delegate Connection
push ctrl and select text field and drag to the right yellow button with name 'Hello3 View Controller'.
release mouse and select delegate.
Implementing the View Controller
Add a Property for the User's Name
In the file hello3ViewController.h
@interface hello3ViewController:
UIViewController{
NSString *userName;
}
...
@property (nonatomic,copy) NSString *userName;
@end
In the file hello3ViewController.m
@implementation hello3ViewController
@synthesize textName = _textName;
@synthesize labelGreeting = _labelGreeting;
@synthesize userName = _userName;
...
- (IBAction)greeting:(id)sender {
self.userName = self.textName.text;
NSString *nameString = self.userName;
if([nameString lenght] == 0){
nameString = @"World";
}
NSString *greeting = [[NSString alloc]
initWithFormat:@"hello, %@!",nameString];
self.labelGreeting.text = greeting;
}
Configure the View Controller as the Text Field's Delegate
In an iOS app, the keyboard is shown automatically when an element that allows text entry becomes the first responder, it is dismissed automatically when the element loses first responder status.
select file hello3ViewController.m file
...snip...
-(BOOL)textFieldShouldReturn:(UITextField *)theTextField{
if(theTextField == self.textName){
[theTextField resignFirstResponder];
}
return YES;
}
...
@end
select the .h file and add some to the @interface line:
@interface hello3ViewController : UIViewController <UITextFieldDelegate>{
...snip...
error message:
unrecognized selector sent to instance ....
solution:
I link the method input to textfield, but I did not delete that.
references:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iPhone101/Articles/05_ConfiguringView.html
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/ios_development_workflow/000-Introduction/introduction.html
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/Introduction/Introduction.html
http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/_index.html
发表评论
-
ionic UI(5)UI and Backend
2016-12-02 03:22 606ionic UI(5)UI and Backend 1 Pr ... -
Stanford Cource(2)Demo App Caculator
2014-06-24 01:29 913Stanford Cource(2)Demo App Ca ... -
Mono on MAC
2014-06-04 03:27 999Mono on MACJust fine the tool f ... -
IOS7 App Development Essentials(4)IPhone5, IPhone5s, IPhone5c
2014-04-11 03:59 1000IOS7 App Development Essentia ... -
IOS7 App Development Essentials(3)NSUserDefaults
2014-04-11 02:58 1022IOS7 App Development Essentia ... -
IPhone and Location(2)Documents Region Monitoring and Region Sample
2013-10-18 05:10 1749IPhone and Location(2)Documents ... -
IPhone and Location(1)Documents User Location
2013-10-18 03:50 1319IPhone and Location(1)Documents ... -
Learn Objective C(6)Programming with Objective-C - Working with Blocks and Deali
2013-10-18 00:02 943Learn Objective C(6)Programming ... -
Learn Objective C(5)Programming with Objective-C - Working with Protocols and Va
2013-10-17 23:47 1013Learn Objective C(5)Programming ... -
Learn Objective C(4)Programming with Objective-C - Encapsulating Data and Custom
2013-10-17 23:23 946Learn Objective C(4)Programming ... -
Learn Objective C(3)Programming with Objective-C - Defining Classes, Working wit
2013-10-17 23:09 1036Learn Objective C(3)Programmi ... -
Learn Objective C(2)Learn Objective-C in Day 6 - 4 ~ 6
2013-10-17 00:30 988Learn Objective C(2)Learn Obj ... -
Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3
2013-10-17 00:22 1124Learn Object C(1) Learn Objec ... -
APNS(4)Recall the Process and Learn Java APNS
2013-04-18 02:48 3491APNS(4)Recall the Process and L ... -
Build the iOS Things with J2Objc
2013-04-12 03:25 2480Build the iOS Things with J2Obj ... -
APNS(3)Write the Easy Client App
2013-01-15 07:23 1748APNS(3)Write the Easy Client Ap ... -
APNS(2)Try to Finish the first Example
2013-01-14 07:56 1560APNS(2)Try to Finish the first ... -
Stanford Cource(1)MVC and Object-C
2012-12-14 14:04 1342Stanford Cource(1)MVC and Objec ... -
Some VI Tips
2012-11-15 04:48 1105Some VI Tips Today, I need to c ... -
MAC Mini Setup
2012-09-25 18:45 1351MAC Mini Setup I am dealing wit ...
相关推荐
《Head-First iPhone开发》是一本专为有编程基础的学习者设计的教程,旨在通过简单、逐步的方法,帮助读者快速掌握构建iPhone应用程序的核心技术。本书并非试图覆盖所有的知识点,而是聚焦于让读者直接进入iPhone...
Head First iPhone and iPad Development
Head First iPhone and iPad Development, 2nd Edition.pdf
O'Reilly - Head First iPhone Development (2009)
Head First iPhone Development(part 2)
Head First iPhone and iPad Development will help you get your first application up and running in no time. You’ll not only learn how to design for Apple’s devices, you’ll also master the iPhone ...
本文将通过标题"iPhone development tableView sample"中的两个范例,详细讲解如何运用UITableView及其与NavigationController和SearchBar的结合。 一、UITableView基础用法 1. 初始化:首先,我们需要创建一个...
Pro iPhone Development with Swift 4: Design and Manage Top Quality Apps English | 2018 | 457 Pages | ISBN : 1484233808
《Head First iPhone & iPad Development》是一本专门为初学者设计的iOS开发入门书籍,旨在帮助读者快速掌握iPhone和iPad应用开发的基础知识。这本书以其独特的“Head First”教学风格,通过直观、生动的方式传授...
Reilly - Head First iPhone Development(part 1)
根据提供的信息,我们可以总结出《Head First iPhone Development》这本书的关键知识点和价值所在。该书针对的是已经具备编程基础的学习者,希望通过一种友好且易于理解的方式来教授如何开发iPhone应用程序。本书的...
包含Pro iPhone Development with Swift 4和Beginning iPhone Development with Swift图书两本,非扫描版 高清带目录。 Swift 4 for Absolute Beginners Develop Apps for iOS(4th) 英文无水印原版pdf 第4版 pdf...
《Beginning iPhone Development》英文版,台湾人翻译为精通iPhone开发。在看这本书之前,确认你已经看了Objective-C,至少你有个大概的知识背景,可下载 http://download.csdn.net/source/2166535 这个来看,看完...
Pro iPhone Development with Swift 5, 2nd Edition (ePUB)