Objective c iphone sdk:CGAffineTransform在iOS 4中不工作?
我正在使用以下代码移动包含UIExtField的uialertview。 alertView应该在键盘出现时向上滑动,在键盘出现时立即向下滑动。下面的代码在ios 3.1.2下运行得非常好。但由于某些原因,它在ios 4.0下无法工作。。。。。问题似乎是我正在进行的转型,但我不知道到底出了什么问题。如果有人知道解决方案,那就太好了!提前谢谢!这是我的密码:Objective c iphone sdk:CGAffineTransform在iOS 4中不工作?,objective-c,ios4,uialertview,cgaffinetransform,Objective C,Ios4,Uialertview,Cgaffinetransform,我正在使用以下代码移动包含UIExtField的uialertview。 alertView应该在键盘出现时向上滑动,在键盘出现时立即向下滑动。下面的代码在ios 3.1.2下运行得非常好。但由于某些原因,它在ios 4.0下无法工作。。。。。问题似乎是我正在进行的转型,但我不知道到底出了什么问题。如果有人知道解决方案,那就太好了!提前谢谢!这是我的密码: - (void)addItemAction{ workoutName = [[UIAlertView alloc] initWithTit
- (void)addItemAction{
workoutName = [[UIAlertView alloc] initWithTitle:@"New Workout" message:@"Insert the name of your new workout:\n " delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Done", nil];
workoutName.cancelButtonIndex = 0;
UITextField *titleField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 90.0, 260.0, 25.0)];
titleField.delegate = self;
titleField.borderStyle = UITextBorderStyleRoundedRect;
titleField.returnKeyType = UIReturnKeyDone;
[workoutName addSubview:titleField];
[workoutName show];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, -70.0);
[workoutName setTransform:myTransform];
[UIView commitAnimations];
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 0.0);
[workoutName setTransform:myTransform];
[UIView commitAnimations];
if ([textField.text length] != 0) {
self.newWorkout = textField.text;
}
else {
self.newWorkout = @"";
}
}
iOS 4更改了UIAlertView中的行为,因此不需要翻译。尝试将翻译包装在if中,以测试您是否使用的是iOS版本<4,并且仅在那里应用它-这有助于我们的情况 例如:
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.0) {
// translation goes here
}
if([[[UIDevice currentDevice]systemVersion]floatValue]<4.0){
//翻译就在这里
}