【问题标题】:iPhone 6/6+ optimization issueiPhone 6/6+ 优化问题
【发布时间】:2014-11-19 03:10:04
【问题描述】:

我花了很多时间尝试为 iPhone6/6+ 优化我的应用程序,但还没有获得一些 UI 元素来优化。

  1. 具有自定义图像背景的 UINavigationBar 和 UISearchBar [已解决]

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navBar"]       forBarMetrics:UIBarMetricsDefault];

UISearchBar 的背景是在故事板中设置的。

UINavigationBar 和 UISearchBar 的 ImageSet 包含 1x、2x 和 3x png 文件。

  1. UITableViewCell:[已解决]

cellForRowAtIndexPath:

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        [cell setBackgroundColor:[UIColor clearColor]];

        UISegmentedControl *mapTypeSelect = [[UISegmentedControl alloc]
                                             initWithItems:
                                             [NSArray arrayWithObjects:
                                                NSLocalizedString(@"MAP_STANDART", nil),
                                                NSLocalizedString(@"MAP_HYBRID", nil),
                                                NSLocalizedString(@"MAP_SATELLITE", nil),
                                                nil]];

        CGSize cF = cell.frame.size;
        [mapTypeSelect setFrame:CGRectMake(10, 5, cF.width-20, cF.height-10)];
  1. UISearchDisplayController 位置(1 - 搜索已激活;2 - 搜索开始):

感谢任何帮助!

谢谢

【问题讨论】:

  • #2:您正在为UISegmentedControl 设置框架。适用于 iPhone 4S、5/5S、6 和 6+ 的自适应 UI 需要使用约束/自动布局。更好的方法是 Storyboard 单元格/xib 单元格(带有约束),而不是在代码中生成单元格,但如果您愿意,可以在代码中添加约束。
  • @RoboticCat:谢谢!我的注意力不集中-在另一堂课上我完全按照你写的那样做))你对#1和#3有什么解决方案吗?
  • 绝对不知道#1 或#3。祝你好运。

标签: ios optimization iphone-6 iphone-6-plus


【解决方案1】:

我从iOS 8 NavigationBar BackgroundImage找到了问题#1的解决方案

在@RoboticCat 回答后编辑

UIEdgeInsets stretchablePart = { .left = 0, .right = 50, .top = 0, .bottom = 0 };
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"navBar"] resizableImageWithCapInsets:stretchablePart resizingMode:UIImageResizingModeStretch] forBarMetrics:UIBarMetricsDefault];

其中 navBar 是 1x、2x 和 3x 图像的 Imageset

【讨论】:

  • 您不希望瓶盖嵌入物覆盖气泡,从而仅拉伸中间部分吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-02
  • 1970-01-01
  • 2015-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多