标签: uiwindow

如何在UIWebView中禁用长触摸?

我想禁用应用程序中的长触摸.我无法控制我在WebView上加载的HTML.

uiwebview uiwindow uiwebviewdelegate

23
推荐指数
2
解决办法
1万
查看次数

makeKeyAndVisible&makeKeyWindow - iphone中的uiwindow

在每个应用程序中

总是写成[window makeKeyAndVisible];

makeKey是什么意思?

iphone cocoa-touch uikit uiwindow

21
推荐指数
2
解决办法
2万
查看次数

使按钮在所有视图控制器上保持不变

我想在我的应用程序的右下角有一个持久性按钮.在所有视图过渡期间,按钮应保持静态.我在确定添加按钮的视图时遇到问题.我知道按钮应该存储在AppDelegate中,但我不知道除了窗口之外添加它的其他视图是什么意思.将其添加到窗口的一个缺点是,当在后台运行应用程序(即电话)时,添加的状态栏填充将按下窗口.一般来说,将它添加到窗口似乎是一个hacky解决方案 - 任何想法?

uiviewcontroller uiview uiwindow ios

20
推荐指数
1
解决办法
1万
查看次数

调整UIView的大小以允许广告单元的空间

我想在UIView的子类上面添加一个广告单元RCTRootView.这将RCTRootView下降约50px.这是我目前的尝试.

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                  moduleName:@"test"
                                               launchOptions:launchOptions];



CGRect frame = rootView.frame;
  frame.size.height -= 50;
  rootView.frame = frame;

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.autoresizesSubviews = YES;
  UIViewController *rootViewController = [[UIViewController alloc] init];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
Run Code Online (Sandbox Code Playgroud)

这是一个React Native项目,所以使用了StoryBoard.如何调整rootView的大小?

如何在UIView(广告单元)上方的UIWindow中实例化和附加viewController?

objective-c uiview uiwindow ios react-native

18
推荐指数
1
解决办法
348
查看次数

使用横向时UIWindow的大小错误

我有一个空的应用程序,没有涉及故事板或xib.我希望有一个隐藏的状态栏,只支持横向.同样,我不想仅在代码中进行这些更改,也不要触摸Info.plist.

问题

我创建了一个带控制器的UIWindow,它表示唯一支持的方向是landscape.在这种情况下,我的UIWindow是在纵向模式的维度中创建的,不会旋转.预期结果将是完全青色的屏幕.

UIWindow破了

这是我的代表:

#import "AppDelegate.h"
#import "AppViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor cyanColor];
  self.window.rootViewController = [[AppViewController alloc] init];
  [self.window makeKeyAndVisible];
  return YES;
}

@end
Run Code Online (Sandbox Code Playgroud)

这是我的控制器:

#import "AppViewController.h"

@implementation AppViewController

- (BOOL)shouldAutorotate {
  return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
  return UIInterfaceOrientationLandscapeLeft;
}

- (BOOL)prefersStatusBarHidden {
  return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
  return UIInterfaceOrientationMaskLandscape;
}

@end
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的

如果我在调用makeKeyAndVisible之后设置了rootViewController,那么一切似乎都起作用.

self.window.backgroundColor = [UIColor cyanColor];
[self.window makeKeyAndVisible];
self.window.rootViewController = [[AppViewController alloc] init]; …
Run Code Online (Sandbox Code Playgroud)

iphone landscape objective-c uiwindow ios

17
推荐指数
2
解决办法
2万
查看次数

设置UIWindow的rootViewController有什么作用?

将视图控制器分配给此属性(以编程方式或使用Interface Builder)将视图控制器的视图安装为窗口的内容视图.

以上引用来自UIWindow的参考.我的问题是关于特定的阶段:

"将视图控制器的视图安装为窗口的内容视图"

确切的内容视图是指什么?

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html

iphone cocoa-touch uiviewcontroller uiwindow ios

16
推荐指数
1
解决办法
6759
查看次数

旋转UIView坐标后,但UIWindow不是?

使用Xcode 4.2.1 iPad iOS 5.0.1,创建一个新的"单视图"iPad项目.在控制器中,添加:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void) dumpView: (UIView *) view {
    CGRect frame = view.frame ;
    CGRect bounds = view.bounds ;
    CGPoint center = view.center ;

    NSLog(@"view [%@]:%d frame=%@ bounds=%@ center=%@"
          ,   NSStringFromClass(view.class)
          ,   [view hash]
          ,   NSStringFromCGRect(frame)
          ,   NSStringFromCGRect(bounds)
          ,   NSStringFromCGPoint(center)) ;
}

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation {

    NSLog(@"INViewController.didRotateFromInterfaceOrientation: %d to %d", fromInterfaceOrientation, self.interfaceOrientation) ;
    [self dumpView: self.view] ;
    [self dumpView: self.view.superview] ;
}
Run Code Online (Sandbox Code Playgroud)

运行它,旋转设备,你会得到:

INViewController.didRotateFromInterfaceOrientation: 2 to 4
view [UIView]   bounds={{0, …
Run Code Online (Sandbox Code Playgroud)

rotation uiview uiwindow ios

15
推荐指数
1
解决办法
9654
查看次数

在UIStatusBar上显示UIWindow后,UIStatusBarStyle发生了变化

我正在显示一个UIWindow UIStatusBar,默认UIStatusBarStyle设置为UIStatusBarStyleLightContent,但是当我UIWindowUIStatusBarStyle开关显示为黑色样式时.

xcode uiwindow ios uistatusbar

15
推荐指数
2
解决办法
3164
查看次数

自定义UIWindows在iOS 8中无法正确旋转

将您的应用程序置于横向模式并执行以下代码:

UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
toastWindow.hidden = NO;
toastWindow.backgroundColor = [[UIColor cyanColor] colorWithAlphaComponent:0.5f];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [toastWindow removeFromSuperview];
});
Run Code Online (Sandbox Code Playgroud)

在iOS 7中,您将在整个屏幕上方获得透明的蓝色覆盖,并在5秒后消失.在iOS 8中,您将获得一个透明的蓝色覆盖,覆盖了一半以上的屏幕

设备截图

这显然与Apple在iOS 8中所做的改变有关,其中屏幕坐标现在面向接口而不是面向设备,但在真正的Apple时尚中,它们似乎在横向模式和旋转方面留下了无数的错误.

我可以通过检查设备方向是否为横向并翻转主屏幕边界的宽度和高度来"修复"这一点,但这似乎是一个可怕的黑客攻击,当Apple在iOS 9中再次更改所有内容时将会破坏.

CGRect frame = [[UIScreen mainScreen] bounds];

if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
    frame.size.width = frame.size.height;
    frame.size.height = [[UIScreen mainScreen] bounds].size.width;
}

UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:frame];
toastWindow.hidden = NO;
toastWindow.backgroundColor = [[UIColor cyanColor] colorWithAlphaComponent:0.5f];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [toastWindow removeFromSuperview];
});
Run Code Online (Sandbox Code Playgroud)

有没有人遇到过这个问题,遇到了更好,更不易解决的问题?

编辑:我知道我可以使用UIView并将其添加到关键窗口,但我想在状态栏上放置一些东西.

objective-c uiwindow ios ios8

15
推荐指数
1
解决办法
1万
查看次数

UIWindow不显示iOS 13中的内容

我正在升级应用程序以使用UISceneiOS 13中定义的新模式,但是该应用程序的关键部分已停止工作。我一直在使用a UIWindow来覆盖屏幕上的当前内容并向用户显示新信息,但是在我正在使用的当前Beta(iOS + XCode beta 3)中,该窗口会出现,但随后会立即消失。

这是我正在使用的代码,现在无法使用:

let window = UIWindow(frame: UIScreen.main.bounds)
let viewController = UIViewController()
viewController.view.backgroundColor = .clear
window.rootViewController = viewController
window.windowLevel = UIWindow.Level.statusBar + 1
window.makeKeyAndVisible()
viewController.present(self, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我已经尝试了许多方法,包括使用WindowScenes来呈现新内容UIWindow,但是找不到任何实际的文档或示例。

我的尝试之一(没有用-窗口出现并立即消失的相同行为)

let windowScene = UIApplication.shared.connectedScenes.first
if let windowScene = windowScene as? UIWindowScene {
    let window = UIWindow(windowScene: windowScene)
    let viewController = UIViewController()
    viewController.view.backgroundColor = .clear
    window.rootViewController = viewController
    window.windowLevel = UIWindow.Level.statusBar + 1
    window.makeKeyAndVisible()
    viewController.present(self, animated: true, completion: …
Run Code Online (Sandbox Code Playgroud)

uiwindow ios swift ios13 uiscenedelegate

15
推荐指数
4
解决办法
7800
查看次数