小编ten*_*ing的帖子

如何在iOS 7上获得不透明的UINavigationBar

是否有任何方法可以使UINavigationBariOS 7的目标成为一种没有半透明效果的纯色?我试过设置backgroundColor,barTintColor,不透明,透明/半透明等等......没有任何效果.

有人知道怎么做吗?

以下是我一直在使用的一些代码块.注意我在上面设置的属性navigationBar.他们都没有,无论以任何顺序或组合都有效.

@property (strong, nonatomic) UITabBarController *tabBarController;

testViewController = [[TestViewController alloc] init];
anotherViewController = [[AnotherViewController alloc] init];
navigationController = [[UINavigationController alloc]
                            initWithRootViewController:testViewController];

navigationController.navigationBar.barTintColor = [UIColor darkGrayColor;
navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController.navigationBar.translucent = YES;
navigationController.navigationBar.opaque = YES;

NSArray *tabBarViewControllers = [NSArray arrayWithObjects:
                                      navigationController,
                                      anotherViewController, nil];
self.tabBarController.viewControllers = tabBarViewControllers;
Run Code Online (Sandbox Code Playgroud)

transparency objective-c uinavigationbar ios7

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

Xcode 10:添加简单约束时的模糊约束错误

我正在使用Xcode 10,并且在尝试为我的视图添加一些非常简单的约束时遇到了一些错误.

我有一个UICollectionViewCell我正在添加一个UIStackView.我调整大小UIStackView以填充单元格并将顶部,底部,左侧和右侧约束设置为安全区域.

我曾经能够在Xcode 9中做到这一点而没有错误,但是,它现在给了我一个错误,我需要指定X位置或宽度和Y位置或高度.即使我让界面构建器添加缺少的约束(中心X和中心Y),它也会产生相同的错误.我觉得这是Xcode 10中的一个错误,但如果对于约束有新的iOS 12要求,我不知道我会感谢他们的一些帮助.

如果我忽略了错误的约束并运行应用程序,则视图无法正确显示.

在此输入图像描述

在此输入图像描述

在此输入图像描述

UPDATE

我当然认为这是一个错误.请注意,在下面的屏幕截图中,即使我在堆栈视图中有子视图,错误也不会消失.此外,当我向顶部,左侧,底部和右侧添加静态填充时,它在布局中无法正确显示,但是当我运行应用程序时它会正确布局.

在此输入图像描述

xcode ios autolayout xcode10

12
推荐指数
1
解决办法
798
查看次数

安全区和导航栏

我正在尝试在 xib 中添加一个导航栏,但导航栏没有填充到顶部,它在相机凹口所在的位置上方留下了空间。请看下面的截图:

在此处输入图片说明

以下是我对导航栏的限制:

在此处输入图片说明

我还尝试将导航栏的顶部约束设置为超级视图。这是这样做的结果:

在此处输入图片说明

我不敢相信这很难。我在这里错过了什么?

uinavigationbar ios autolayout safearealayoutguide iphone-x

10
推荐指数
2
解决办法
6100
查看次数

从 UIViewController 导航到 SwiftUI 视图

我在网上看到了很多关于如何从SwiftUI 视图导航到UIViewController的内容,但关于如何UIViewController导航SwiftUI 视图的内容却很少。有人知道怎么做吗?

uiviewcontroller ios swift swiftui

7
推荐指数
1
解决办法
2810
查看次数

Magnification API的问题

我在Microsoft提供Magnification API时遇到问题.这是一个用C++编写的API,所以要在C#中使用它,你必须使用一系列.dll导入,如本问题所述.

我的问题出现在我放大倍率工作之后.我正在使用鼠标放大屏幕的预定义区域,放大倍率设置为矩形,矩形填充WinForm,我将表格放在鼠标顶部(鼠标位于窗体中心),表格将跟随我的鼠标在屏幕上.

大约80%的时间,该应用程序将启动黑屏.我尝试了许多不同类型的更新,但无法找到修复程序.放大倍数不会显示,它只会显示黑屏.from上没有任何东西会出现,只有黑屏.总之,由于Magnification API,只会显示黑屏.

c# magnification-api

6
推荐指数
1
解决办法
1480
查看次数

React Native:无法连接到开发服务器

我有一个非常简单的 React Native 项目,我正在尝试开始工作。它是一个 iOS 项目,只需将 RCTRootView 添加到 UIViewController。当我从 Xcode 运行应用程序时,出现一个带有错误的红色屏幕:

Could not connect to development server.

Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate
Run Code Online (Sandbox Code Playgroud)

AppDelegate.h

@property (strong, nonatomic) RCTRootView *rootView;
Run Code Online (Sandbox Code Playgroud)

AppDelegate.m 中 application: didFinishLaunchingWithOptions:

NSURL *jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"];
self.rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"HelloReact" initialProperties:nil launchOptions:launchOptions];
Run Code Online (Sandbox Code Playgroud)

ViewController.m 中 viewDidAppear:

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; …
Run Code Online (Sandbox Code Playgroud)

objective-c node.js ios reactjs react-native

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

应用透视变换而不旋转

我一直在尝试对UIView执行透视变换.我一直在这个例子中工作.

但是,该示例在视图上应用旋转以及透视更改.有没有办法在没有旋转的情况下改变视图的视角?可能看起来像这样的东西:

在此输入图像描述

我一直试图去除旋转,但是当我做透视变换时不会应用.我找不到任何只是改变观点的例子.提前致谢.

core-animation objective-c perspectives catransform3d ios

4
推荐指数
1
解决办法
2572
查看次数

显式设置某些行的行高,但对其他行使用estimatedRowHeight

我有一个UITableViewCell包含UIWebView作为子视图的.Web视图填充整个单元格.我estimatedRowHeight用来计算行高.但是,在构建表视图时,单元格没有高度,因为Web视图未加载其内容,因此单元格没有内容.因此,estimatedRowHeight返回44而不是Web视图内容的正确高度.

有没有人知道如果没有立即设置内容我怎么能正确计算行的高度?有没有办法估计某些单元格的高度,并在同一个表视图中明确设置其他单元格的高度?

这就是我使用的方式estimatedRowHeight:

self.tableView.estimatedRowHeight = 200;
self.tableView.rowHeight = UITableViewAutomaticDimension;
Run Code Online (Sandbox Code Playgroud)

我没有使用委托方法.我试过了,但它没有改变结果.我正在使用的单元格有一个xib,它也使用自动布局约束.为清楚起见,单元格确实出现,并且Web视图确实已添加到单元格中.问题是单元格的高度不足以显示整个Web视图.Web视图为音频播放器加载HTML嵌入代码.

row-height uiwebview uitableview ios8

4
推荐指数
1
解决办法
1859
查看次数

将小数纬度/经度坐标转换为iPad屏幕坐标

我有一个纬度/经度小数点坐标,我想将其转换为适合iPad坐标系区域的点.

我的代码采用纬度/经度坐标并将它们转换为笛卡尔坐标(基于此问题:转换为笛卡尔坐标)转换结果为(2494.269287,575.376465).

这是我的代码(没有编译或运行时错误):

#define EARTH_RADIUS 6371

- (void)drawRect:(CGRect)rect
{
    CGPoint latLong = {41.998035, -116.012215};

    CGPoint newCoord = [self convertLatLongCoord:latLong];

    NSLog(@"Cartesian Coordinate: (%f, %f)",newCoord.x, newCoord.y);

    //Draw dot at coordinate
    CGColorRef darkColor = [[UIColor colorWithRed:21.0/255.0
                                            green:92.0/255.0
                                             blue:136.0/255.0
                                            alpha:1.0] CGColor];
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, darkColor);
    CGContextFillRect(context, CGRectMake(newCoord.x, newCoord.y, 100, 100));

}

-(CGPoint)convertLatLongCoord:(CGPoint)latLong
{
    CGFloat x = EARTH_RADIUS * cos(latLong.x) * cos(latLong.y);
    CGFloat y = EARTH_RADIUS * cos(latLong.x) * sin(latLong.y);

    return CGPointMake(x, y);
}
Run Code Online (Sandbox Code Playgroud)

如何将小数点坐标转换为将显示在iPad屏幕上的坐标?

objective-c latitude-longitude ios cartesian-coordinates

3
推荐指数
1
解决办法
3091
查看次数

UIAlertController中的自定义视图

我想把一个自定义视图放在一个UIAlertController.我在调整自定义视图的大小时遇到​​了一些奇怪的问题.

我想自定义视图跨越的宽度UIAlertController,无论可能是什么.我正在使用CGRectGetWidth(alertController.view.bounds)获取警报控制器的宽度.但是,这似乎是返回整个视图的宽度.使用view.frame并没有什么区别.

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"My Title" message:nil preferredStyle:UIAlertControllerStyleAlert];

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(alertController.view.bounds), 50)];
view.backgroundColor = [UIColor blueColor];

[alertController.view addSubview:view];
[self presentViewController:alertController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

这产生了以下结果.我有同样的问题试图获得的X,Y宽度和高度属性UIAlertController.有没有人知道如何在不使用硬编码数字的情况下将此视图放在警报控制器的中间?

在此输入图像描述

custom-controls subview custom-view ios uialertcontroller

3
推荐指数
1
解决办法
9162
查看次数