我在一周前提交了我的应用程序,今天收到了可怕的拒绝电子邮件.它告诉我我的应用程序无法被接受,因为我使用的是非公共API; 具体来说,它说,
应用程序中包含的非公共API是firstResponder.
现在,违规的API调用实际上是我在SO上找到的解决方案:
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView *firstResponder = [keyWindow performSelector:@selector(firstResponder)];
Run Code Online (Sandbox Code Playgroud)
如何在屏幕上显示当前的第一响应者?我正在寻找一种不会让我的应用被拒绝的方法.
是否有内置的方式从a UIView到它UIViewController?我知道你可以从UIViewController它UIView通过它,[self view]但我想知道是否有反向参考?
由于ShouldAutorotateToInterfaceOrientation在iOS 6中已弃用并且我使用它来强制特定视图仅限于纵向,在iOS 6中执行此操作的正确方法是什么?这仅适用于我的应用的一个区域,所有其他视图都可以旋转.
我正在尝试使用以下代码从应用程序委托中呈现视图控制器:
- (void)interstitialViewControllerRequestSucceeded:(UIViewController *)interstitialViewController
{
[self.window.rootViewController presentViewController:(UIViewController *)interstitialViewController animated:YES completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)
它将在初始视图控制器上显示插页式广告但不显示其他插页式广告.我希望它显示在连接到导航控制器的每一个上.
如何修改此代码以实现该目标?
我如何从应用程序委托中获取当前活动视图(当前正由用户查看的主视图)以供参考?
我正在使用带有故事板的xcode 5.1.1.我在主菜单上有一个按钮,它会使用此代码弹出到另一个视图控制器
VC *secondVC = [[VC alloc] init];
[self presentViewController:secondVC animated:YES completion: nil];
Run Code Online (Sandbox Code Playgroud)
我有这个代码的后退按钮
[self dismissViewControllerAnimated:YES completion: nil];
Run Code Online (Sandbox Code Playgroud)
当我弹出secondVC xcode给我的错误:
不鼓励在分离的视图控制器上呈现视图控制器
<UINavigationController: 0x8c94510>.
我也有旋转问题,它无法正常工作.
在根ViewController中,我将全屏呈现模态视图控制器.这在大多数情况下都可以正常工作.我遇到的问题是当另一个Modal ViewController作为表单打开时.发生这种情况时,我的FullScreen VC显示在表单的后面.我该怎么办?
基本上这个" DemoViewController"作为我的应用程序的屏幕保护程序.
demoVideoController = new DemoVideoController(this) { View = { Frame = View.Bounds } };
demoVideoController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
PresentViewController(demoVideoController, false, null);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有一个UIAlertView.当用户点击警报视图中的按钮时,我想显示一个新按钮UIViewController.
为了实现这一点,我需要知道哪个视图控制器当前在屏幕上可见,因为该特定视图控制器是呈现新视图控制器的正确视图控制器.
问题是我的应用程序中有一个复杂的视图控制器层次结构,包括a UINavigationController和a UITabBarController(以及其他).所以我不能简单地self.visibleViewController用来获取当前可见的视图控制器.
我已经在Stackoverflow上找到了一个可能的解决方案,但我想找到一个更简洁的解决方案而无需挖掘整个视图控制器堆栈.
我正在尝试从我制作的类中显示AlertController.由于AlertController是UIResponder的子类,我使用Xcode建议我的以下代码行
superclass?.presentViewController(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
但我无法编译,因为AnyClass?没有任何成员presentViewController.我的类是NSObject的子类.
还有其他方法吗?谢谢
我想在应用程序运行时触发通知时显示警报,这是我用于本地通知的教程.在教程中,它用于UIAlertView显示警报并且它可以工作,这里是代码:
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
// Point for handling the local notification when the app is open.
// Showing reminder details in an alertview
UIAlertView(title: notification.alertTitle, message: notification.alertBody, delegate: nil, cancelButtonTitle: "OK").show()
}
Run Code Online (Sandbox Code Playgroud)
但它警告UIAlertView在iOS 9中已弃用,所以我使用了UIAlertController,但是当我运行它时会发出警告:
Attempt to present <UIAlertController: 0x7c322a00> on <xxx> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
这是我的didReceiveLocalNotification方法:
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
let alert = UIAlertController(title: "", message: notification.alertBody, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", …Run Code Online (Sandbox Code Playgroud) 我正在尝试在线程中打开文件,这是我的代码:
DispatchQueue.main.async(execute: { () -> Void in
var documentsURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).appendPathComponent(“File.pdf")
self.docController = UIDocumentInteractionController.init(url: documentsURL as URL)
self.docController?.delegate = self as? UIDocumentInteractionControllerDelegate
self.docController?.presentPreview(animated: true)
self.docController?.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
})
Run Code Online (Sandbox Code Playgroud)
当移动到主屏幕时,会显示此警告并且文件未打开
Warning: Attempt to present <_UIDocumentActivityViewController: 0x...> on <HCM.PrintVacationDecisionVC: 0x...> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
有什么帮助解决这个问题?
我是 iOS 编程的新手,我已经实现了 UITableViewController 并在我的主页上像弹出窗口一样获得了 tableViewController 设计,背面我在主页和 tableViewController 之间添加了模糊效果。模糊效果视图和 UITableView 都作为子视图添加到主屏幕中。
这是我的问题:
当我验证 tableViewController 的 UITextfields 时,alertController 出现在模糊效果和 tableViewController 的背面,我需要在 tableViewController 上使用它。
我怎样才能得到??
我使用下面的代码来实现模糊效果和 tableView:
UIVisualEffect *blurEffect;
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[[UIApplication sharedApplication].keyWindow addSubview:visualEffectView];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
viewaccept = (AcceptViewController *)[storyboard instantiateViewControllerWithIdentifier:@"AcceptViewController"];
[viewaccept willMoveToParentViewController:self];
CGRect screen = [[UIScreen mainScreen] bounds];
CGRect newFrame = CGRectMake(0,screen.size.height/4, self.view.frame.size.width, 350);
UIEdgeInsets insets = UIEdgeInsetsMake(0,10,0,10);
viewaccept.view.frame = UIEdgeInsetsInsetRect(newFrame,insets);
CGRect splitframe = …Run Code Online (Sandbox Code Playgroud) ios ×10
objective-c ×5
cocoa-touch ×2
swift ×2
uiview ×2
xcode ×2
addsubview ×1
alert ×1
amslidemenu ×1
appdelegate ×1
ios6 ×1
nsobject ×1
subviews ×1
swift2 ×1
swift3 ×1
uialertview ×1
xamarin ×1
xamarin.ios ×1