Tag: cocoa touch

UITextView光标在帧更改帧之后

我有一个包含UITextView的UIViewCOntroller 。 当键盘出现时,我调整它像这样: #pragma mark – Responding to keyboard events – (void)keyboardDidShow:(NSNotification *)notification { NSDictionary* info = [notification userInfo]; CGRect keyboardSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGRect newTextViewFrame = self.textView.frame; newTextViewFrame.size.height -= keyboardSize.size.height + 70; self.textView.frame = newTextViewFrame; self.textView.backgroundColor = [UIColor yellowColor]; } – (void)keyboardWillHide:(NSNotification *)notification { NSDictionary* info = [notification userInfo]; CGRect keyboardSize = [[info […]

旋转UIView的中心,但几次

我想旋转一些UIView的中心,所以简单的代码就像(伪代码): [UIView beginAnimations:@"crazyRotate" context:nil]; [UIView setAnimationDuration:1.0]; someview.transform = CGAffineTransformMakeRotation(angle); [UIView commitAnimations] 现在如果我设置angular度说M_PI / 2的东西很好地旋转。 如果我将它设置为2 * M_PI,那么它“没有”。 我可以理解,matrix转化为什么都不做(旋转360意味着“停留”在某种意义上),但是,我想旋转它5次(想到一个报纸旋转的规模来到你的效果 – 我不是善于描述,希望有人能理解)。 所以,我试着把设置angular度加到180度(M_PI)并添加一个嵌套的animatationBlock 。 但我想,因为我设置相同的属性( someview.transition )再忽略它)。 我尝试将angular度为M_PI的animation的重复计数设置为2,但似乎只是简单地旋转180,回到直线位置,然后再次启动旋转。 所以,我有点想法,任何帮助表示赞赏! –t

是否有可能将NSMutableArray或NSDictionary数据保存为文件在iOS?

我想保存一个NSMutableArray或NSDictionary作为永久文件。 然后,我想稍后重新打开文件。 这可能吗? 如果是这样,我该怎么办呢?

iOS捏尺和两个手指同时旋转

这是我的代码: viewDidLoad中: UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinch:)]; [self.canvas addGestureRecognizer:pinch]; pinch.delegate = self; UIRotationGestureRecognizer *twoFingersRotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(pinchRotate:)]; [[self canvas] addGestureRecognizer:twoFingersRotate]; twoFingersRotate.delegate = self; 代码捏和旋转: -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } -(void)pinchRotate:(UIRotationGestureRecognizer*)rotate { SMImage *selectedImage = [DataCenter sharedDataCenter].selectedImage; switch (rotate.state) { case UIGestureRecognizerStateBegan: { selectedImage.referenceTransform = selectedImage.transform; break; } case UIGestureRecognizerStateChanged: […]

NSString到NSArray

我想分裂成一个NSArray的NSString 。 例如,给出: NSString *myString=@"ABCDEF"; 我想要一个NSArray像: NSArray *myArray={A,B,C,D,E,F}; 如何用Objective-C和Cocoa做到这一点?

UITableViewCell的UITextField子视图,获取单元格的indexPath

我已经添加了一个UITextField作为UITableViewCell的子视图。 然后我添加了一个target和selector以便我可以知道何时UIControlEventEditingChanged 。 这很好,但我想知道UITextField所在单元格的indexPath ,因为它可以添加到任意数量的单元格中。 这可能吗? 基本上我想find一个UITableViewCell的父视图。

如何在iOS中创build不使用Unicode的下标字符

我一直在尝试一段时间来创build一个NSString的下标字符没有成功。 是否有可能在iOS中做到这一点? 我需要一种方法来将string中的字符更改为下标或上标,并且由于Unicode不具有所有字母,因此无法使用Unicode。 我的猜测可能是使用HTML标签<sub>和<sup>但我没有find一种方法将所述HTML标签转换为NSString。

iPhone XMPP应用程序运行的背景

我创build了一个使用XMPP框架的聊天应用程序。当我退出应用程序(进入后台模式),我想接收聊天消息,并且还需要显示图标徽章…我该怎么做?

计算UITextView中的行数,按帧大小包装行

我想知道什么时候一个文本被包装的文本框架的视图是否有任何分隔符,我们可以识别文本是否被包装或不。 例如,如果我的文本视图的宽度为50像素,并且文本超过了该值,则会将文本包装到下一行。 我想计算我的文本视图中的行数。 现在“\ n”和“\ r”不帮助我。 我的代码是: NSCharacterSet *aCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"\n\r"]; NSArray *myArray = [textViewText componentsSeparatedByCharactersInSet:aCharacterSet]; NSLog(@"%d",[myArray count]);

如何在iPhone UILabel中设置字距

我正在开发一个iPhone应用程序,我想在UILabel中设置字距。 我写的代码(可能围绕kCTKernAttributeName )似乎是错误的。 我怎样才能解决这个问题? NSMutableAttributedString *attStr; NSString *str = @"aaaaaaa"; CFStringRef kern = kCTKernAttributeName; NSNumber *num = [NSNumber numberWithFloat: 2.0f]; NSDictionary *attributesDict = [NSDictionary dictionaryWithObject:num forKey:(NSString*)kern]; [attStr initWithString:str attributes:attributesDict]; CGRect frame1 = CGRectMake(0, 0, 100, 40); UILabel *label1 = [[UILabel alloc] initWithFrame:frame1]; label1.text = attStr [self.view addSubview:label1];