如何限制UITextField除点和下划线之外的特殊字符?
我已经尝试了下面的代码片段,但没有运气:
#define ACCEPTABLE_CHARECTERS @" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *acceptedInput = [NSCharacterSet characterSetWithCharactersInString:ACCEPTABLE_CHARECTERS];
if (![[string componentsSeparatedByCharactersInSet:acceptedInput] count] > 1){
NSLog(@"not allowed");
return NO;
}
else{
return YES;
}
}
Run Code Online (Sandbox Code Playgroud) 什么是iPhone 5的图像命名约定,如@ 2x用于视网膜屏幕.
嗨,我正在使用MFMessageComposeViewController在我的iOS项目中发送短信,我的代码如下所示,
MFMessageComposeViewController *message = [[MFMessageComposeViewController alloc] init];
message.delegate = self;
message.recipients = [NSArray arrayWithObject:@"xxxxxx"];
message.body = @"blha blah,,,,";
[self presentModalViewController:message animated:YES];
Run Code Online (Sandbox Code Playgroud)
并且在我的代码中我定义了MFMessageComposeViewControllerDelegate方法didFinishWithResult但是当任务完成时,控件没有调用这个didFinishWithResult委托方法.可能是什么问题?
任何帮助都提前感谢.
ObjectiveC中b/w imageNamed和imageWithContentsOfFile有什么区别
我正在为我的应用程序编写一个单独的NSObject类,用于WebService调用,所以我有一个混乱,我需要明确编写init方法,如下所示,
-(id)init{
self = [super init];
return self;
}
Run Code Online (Sandbox Code Playgroud)
或者即使我忽略了这一点并尝试从另一个类调用它会工作吗?
任何人都可以告诉块动画相当于下面的代码片段吗?
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.navigationController.view cache:NO];
NextViewController *next = [[NextViewController alloc]
initWithNibName:@"NextViewController" bundle:nil];
[self.navigationController pushViewController:next animated:YES];
[next release];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud) 我从服务器数据中获取UTF8编码数据就好Less%20than%20100但我需要这些数据Less than 100(解码格式),我的NSXMLParsing委托方法就像
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"option"]) {
dict = [[NSMutableDictionary alloc]init];
[dict setValue:[attributeDict objectForKey:@"text"] forKey:@"text"];/* Here itself i need to decode & save in to my dict */
}
Run Code Online (Sandbox Code Playgroud)
如何解码这些数据.
在启用ARC的项目中,我可以在self中使用的等效关键字是什么?例如:[self mymethod]; 什么是ARC等效的这种方法调用?
我在我的代码中使用NSDictionary的writeToFile属性我正在尝试将字典更新到文档目录,如下所示,
NSDictionary *revisionDict = [NSDictionary dictionaryWithObject:currentItem.rev forKey:destPath];
NSArray *documentDirPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentDirPath objectAtIndex:0];
NSString *dictPath = [documentsDir stringByAppendingPathComponent:@"Revision.dictionary"];
[revisionDict writeToFile:dictPath atomically:YES];
Run Code Online (Sandbox Code Playgroud)
这里的问题是我的字典,而不是每次迭代都被新条目更新,它会被新条目所覆盖.如何更新我的字典是否有任何替代writeToFile,任何帮助提前赞赏.
嗨我使用下面的代码将截图附加到mailcomposer,我没有设备检查所以这将在实际设备上工作?
-(void)launchMailAppOnDevice
{
/*Take a SnapShot of current screen*/
UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * imageData = UIImageJPEGRepresentation(image, 1.0);
NSString *recipients = @"mailto:xyz@abc.com?cc=@\"\"&subject=blah!!blah!!";
NSString *body = @"&body=blah!!blah!!";
NSString *email = [NSString stringWithFormat:@"%@%@%@", recipients, body, imageData];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
Run Code Online (Sandbox Code Playgroud) ios ×10
objective-c ×10
iphone ×8
xcode ×5
mfmessagecomposeviewcontroller ×2
cocoa-touch ×1
escaping ×1
nsdictionary ×1
nsobject ×1
nsxmlparser ×1
uiimage ×1
uitextfield ×1
xcode4.3 ×1