ios的计算字符串的长度
2013-05-15 16:01
405 查看
1.
lengthViewController.h
import
<UIKit/UIKit.h>
@interface lengthViewController :
UIViewController{
IBOutlet UILabel *dispLenLabel;
IBOutlet UITextField *inputField;
}
-(IBAction)btnDown:(id)sender;
@end
2.
lengthViewController.m
#import
"lengthViewController.h"
@implementation lengthViewController
- (void)didReceiveMemoryWarning
{
[super
didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super
viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super
viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super
viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super
viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super
viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation !=
UIInterfaceOrientationPortraitUpsideDown);
}
-(IBAction)btnDown:(id)sender{
int len=inputField.text.length;
if(len){
//如果不为空
dispLenLabel.text=[NSString
stringWithFormat:@"%d",len];
}else{
//给出警告
UIAlertView *alert=[[UIAlertView
alloc]initWithTitle:@"错误提示" message:@"请输入内容"
delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil,
nil];
[alert
show];
// [alert release];
}
}
@end
lengthViewController.h
import
<UIKit/UIKit.h>
@interface lengthViewController :
UIViewController{
IBOutlet UILabel *dispLenLabel;
IBOutlet UITextField *inputField;
}
-(IBAction)btnDown:(id)sender;
@end
2.
lengthViewController.m
#import
"lengthViewController.h"
@implementation lengthViewController
- (void)didReceiveMemoryWarning
{
[super
didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super
viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super
viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super
viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super
viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super
viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation !=
UIInterfaceOrientationPortraitUpsideDown);
}
-(IBAction)btnDown:(id)sender{
int len=inputField.text.length;
if(len){
//如果不为空
dispLenLabel.text=[NSString
stringWithFormat:@"%d",len];
}else{
//给出警告
UIAlertView *alert=[[UIAlertView
alloc]initWithTitle:@"错误提示" message:@"请输入内容"
delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil,
nil];
[alert
show];
// [alert release];
}
}
@end
相关文章推荐
- iOS计算中英混合的的字符串长度
- iOS中动态计算字符串的长度
- iOS计算中英文混合字符串长度的方法
- ios 计算字符串长度<转>
- iOS 字符串长度计算boundingRectWithSize遇到 " \r\n"的时候,后面的字符串长度返回0 在swift中使用pod导入第三方库时,注意事项
- iOS如何计算字符串的长度
- iOS 计算中英文混合字符串的长度
- Objective-C ,ios,iphone开发基础:如何判断一个字符是不是中文字符。计算一段字符串的长度。
- iOS开发 计算字符串单行的长度
- IOS计算字符串的长度和宽度
- iOS 根据字符串样式、字符串长度计算字符串所占大小
- ios 字符串长度计算
- 字符串 长度计算
- php 计算字符串长度时间测试
- ios开发中计算字符串的高度
- PHP 字符串长度计算函数strlen() 正确的计算 中文汉字长度的方法 与mb_strlen()应用
- 计算字符串长度
- 计算字符串最后一个单词的长度(牛客网)
- 计算中英文混合字符串的长度