【问题标题】:CGAffineTransformTranslate not working in iOS 3.1.3CGAffineTransformTranslate 在 iOS 3.1.3 中不起作用
【发布时间】:2011-06-14 21:15:25
【问题描述】:


我正在尝试将 UIAlertView 从屏幕中心的默认位置移动到顶部。我正在使用下面的代码,它适用于 iOS 4,但不能在 3 上运行。
有人知道吗?

UIAlertView *newSubscriptionAlertView = [[UIAlertView alloc] initWithTitle:@"Ndrysho abonimin" message:@" " delegate:self cancelButtonTitle:@"Anullo" otherButtonTitles:@"Ruaj", nil]; subscriptionNameField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 22.0)]; subscriptionNameField.text = [[订阅 objectAtIndex:changeCode] title]; subscriptionNameField.autocorrectionType = UITextAutocorrectionTypeNo; subscriptionNameField.autocapitalizationType = UITextAutocapitalizationTypeNone; [subscriptionNameField setBackgroundColor:[UIColor whiteColor]]; [newSubscriptionAlertView addSubview:subscriptionNameField]; [订阅名称字段成为FirstResponder]; [订阅名称字段发布]; CGAffineTransform moveUp = CGAffineTransformTranslate(newSubscriptionAlertView.transform, 0.0, 0.0); [newSubscriptionAlertView setTransform:moveUp]; [newSubscriptionAlertView 显示]; [newSubscriptionAlertView 发布];

【问题讨论】:

  • 我不知道你期望发生什么,但CGAffineTransformTranslate(someTransform, 0, 0) 将返回someTransform 给你。
  • 这就是为什么 setTransform 方法在下面一行中使用。我认为语法没问题,因为它适用于 iOS 4.0+
  • 即使我这样做:newSubscriptionAlertView.transform = CGAffineTransformTranslate(newSubscriptionAlertView.transform, 0.0, 0.0);我也有同样的问题。这意味着它适用于 4 但不适用于 3。:(

标签: ios uialertview cgaffinetransform ios3.0


【解决方案1】:

解决办法是这样的:

if (!([[[UIDevice currentDevice] systemVersion] floatValue] > 4.0)) { //这是针对4.0以下的iOS版本 changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 70.0f); } 别的 { //这是iOS4.0+ changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 0.0f); }

【讨论】:

    猜你喜欢
    • 2018-11-30
    • 2012-02-14
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    • 2012-01-16
    • 2013-02-12
    • 1970-01-01
    相关资源
    最近更新 更多