【问题标题】:Updating Parse to UIAlertCotroller with Cocapods使用 Cocoapods 将 Parse 更新为 UIAlertController
【发布时间】:2016-03-10 00:18:54
【问题描述】:

在 IOS 上工作一段时间后,我刚刚更新到 Xcode 7.1 版本 7.1.1 (7B1005)。

更新后,我在使用 Parse 框架运行项目时遇到问题,因此我再次运行 pod install 以更新所有内容。 (下面的 pod 输出)

Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Using Bolts (1.2.2)
Using Parse (1.8.5)
Using ParseUI (1.1.6)
Using PercentEncoder (1.0.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 4 total
pods installed.

这工作正常,现在项目再次完美构建和运行,但有一个明显的例外。

我现在收到有关在 IOS9 中弃用 UIAlertView 的警告(我知道这已被 UIAlertCotroller 取代)。这些警告指向 ParseUI 框架文件。

'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

以下所有罚款都会收到相同的警告。

PFUIAlertView.h
PFLogInViewController.m
PFQueryCollectionViewController.m
PFQueryTableViewController.m
PFUIAlertView.m

发生这种情况是因为 Parse UI 已过时吗?还是我错过了什么或做错了什么?

我的代码都没有任何错误或警告。

我看了高低,似乎没有其他人有这个问题。

请帮助我卡住了,不知道穿什么好看。

【问题讨论】:

  • 现在已更新到 Xcode 7.2,但问题仍然存在。

标签: ios xcode parse-platform cocoapods xcode7


【解决方案1】:

Parse-UI 项目似乎已过期。查看标题,它扩展了UIAlertView

// PFUIAlertView.h
#import <UIKit/UIKit.h>

@interface PFUIAlertView : UIAlertView

+ (void)showAlertViewWithTitle:(NSString *)title
                         error:(NSError *)error;
+ (void)showAlertViewWithTitle:(NSString *)title
                       message:(NSString *)message;
+ (void)showAlertViewWithTitle:(NSString *)title
                       message:(NSString *)message
             cancelButtonTitle:(NSString *)cancelButtonTitle;
@end

// PFUIAlertView.m
+ (void)showAlertViewWithTitle:(NSString *)title
                       message:(NSString *)message
             cancelButtonTitle:(NSString *)cancelButtonTitle {
    UIAlertView *alertView = [[self alloc] initWithTitle:title
                                                 message:message
                                                delegate:nil
                                       cancelButtonTitle:cancelButtonTitle
                                       otherButtonTitles:nil];
    [alertView show];
}

不管它的价值如何,有一个open issue,但是这方面的工作似乎已经停滞不前。也许将它提出来将有助于进行更新。

你可以找到完整的源代码here

【讨论】:

  • 这就是我的想法。谢谢你。我是否正确,如果我用 UIAlertController 替换 ParseUI 文件中的 UIalertview 代码,就像我在自己的代码中一样,它应该解决问题,直到 Parse 有更新?
  • @joffd 我不这么认为。 UIAlertControllerUIViewController 的子类,因此需要像处理任何其他视图控制器一样处理它。另外,设置按钮非常不同。我的建议是避免一起使用PFUIAlertView(如果可能的话),直接使用UIAlertController。老实说,it is easier to work with。其次,如果您开始编辑 Parse 文件,这些编辑将在下一个 pod updatepod install 时丢失。
  • @joffd 你可以查看method swizzling 并用你自己的替换 PFUIAlertView 的实现。不过,我无能为力。
猜你喜欢
  • 2015-09-28
  • 1970-01-01
  • 1970-01-01
  • 2014-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-14
相关资源
最近更新 更多