UIActivityIndicatorView *refreshMum = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
文本控件改變鍵盤大寫鍵:
_multiDomainTextView.autocapitalizationType =UITextAutocapitalizationTypeNone;
cell 加控件:
//在繪製單元格時
cell.accessoryView = button ;
提示控件:
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:@"您輸入的域名「%@」不正確",_multiDomainTextView.text] message:@"您選擇了英文查詢狀態,請輸入英文域名!\n例如:taobao" delegate:nil cancelButtonTitle:@"肯定" otherButtonTitles:nil];
[alert show];
字符串拆分
NSString * textViewText=@"aaaaaaa \n aaaa aaaa \n ";
textViewText = [textViewText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //去掉空格和換行
//根據換行符將字符串拆分紅數組
NSMutableArray * textArrayNumberOne = [[NSMutableArray alloc]init];
[textArrayNumberOne setArray:[textViewText componentsSeparatedByString:@"\n"]];
NSLog(@"%@",textArrayNumberOne);
[alert release];
[textArrayNumberOne release];
把該數組中爲空的元素去掉:
for (int i = 0; i < textArrayNumberOne.count; i++)
if ([[textArrayNumberOne objectAtIndex:i] isEqualToString:@""]) {
[textArrayNumberOne removeObjectAtIndex:i];
}
}
將字符串拼接:
[suffixedArray addObject:[NSString stringWithFormat:@"%@%@",[textArrayNumberOne objectAtIndex:i],[suffixArray objectAtIndex:j]]];
//將拼接好的字符串用,隔開
NSMutableString * str= [[[NSMutableString alloc] init] autorelease];
for (int i = 0; i<suffixedArray.count; i++)
{
if (i>0) {
[str appendString:@","];
}
[str appendString:[suffixedArray objectAtIndex:i]];
}
NSLog(@"%@",str);
判斷字符串中是否包含中文:
將字符串中的字符取到一個一個字符循環判斷
int length = [_multiDomainTextView.text length];
for (int i=0; i<length; ++i)
{
NSRange range = NSMakeRange(i, 1);
NSString *subString = [_multiDomainTextView.text substringWithRange:range];
const char *cString = [subString UTF8String];
if (strlen(cString) == 3)
{
_language=YES;
break;
}
}