小编无夜之*_*之星辰的帖子

WKWebView中的字体看起来比UIWebView中的字体小

我将UIWebView更改为WKWebView,但是,使用相同的html,WKWebView中的字体看起来比UIWebView中的字体要小.我不希望这种情况发生,所以有什么方法可以避免这种变化吗?

html objective-c uiwebview swift wkwebview

18
推荐指数
3
解决办法
5809
查看次数

如何使富文本在颤振中垂直居中对齐?

import 'package:flutter/material.dart';

class DraftPage extends StatefulWidget {
  DraftPage({Key key}) : super(key: key);

  @override
  _DraftPageState createState() => _DraftPageState();
}

class _DraftPageState extends State<DraftPage> {
  @override
  Widget build(BuildContext context) {
    final bottomTextStyle = TextStyle(
      fontSize: 12,
      fontWeight: FontWeight.w500,
      color: Colors.red,
    );
    return Scaffold(
      appBar: AppBar(
        title: Text('Test'),
      ),
      body: Container(
        alignment: Alignment.center,
        width: 300,
        height: 57,
        decoration: BoxDecoration(
          color: Colors.yellow,
        ),
        child: Text.rich(
          TextSpan(
            children: [
              TextSpan(
                text: 'AB',
                style: bottomTextStyle,
              ),
              TextSpan(
                text: 'CD',
                style: TextStyle(
                  fontSize: 40,
                  fontWeight: FontWeight.w500,
                  color: …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

如何在 Dart 中将原始值分配给枚举?

在 Swift 中,您可以轻松地将原始值分配给枚举,例如:

enum Game: Int {
    case lol = 1
    case dnf = 2
    case dota = 3
}
Run Code Online (Sandbox Code Playgroud)

但是,您不能将原始值分配给 Dart 中的枚举:

enum Game {
  lol = 1,
  dnf = 2,
  dota = 3,
}
Run Code Online (Sandbox Code Playgroud)

它显示错误,你只能使用最简单的枚举:

enum Game {
  lol,
  dnf,
  dota,
}
Run Code Online (Sandbox Code Playgroud)

实在是让我很失望。

有什么办法可以像 Swift 一样将原始值分配给 Dart 的枚举吗?

enums dart flutter

12
推荐指数
2
解决办法
6679
查看次数

NSTimer 的最小有效时间间隔是多少?

我想用来NSTimer增加标签上显示的数字。

这是我的代码:

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(90, 90, 90, 30)];
[self.view addSubview:self.numberLabel];


self.timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(refreshText) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop]addTimer:self.timer forMode:NSRunLoopCommonModes];
}

- (void)refreshText{

NSDate *beginDate = [NSDate date];

static NSInteger a = 0;
a ++;

self.numberLabel.text = [NSString stringWithFormat:@"%ld",a];

if (a == 1000) {

    NSDate *endDate = [NSDate date];

    NSTimeInterval durationTime = [endDate timeIntervalSinceDate:beginDate];
    NSTimeInterval intervalTime = self.timer.timeInterval; …
Run Code Online (Sandbox Code Playgroud)

objective-c nstimer ios

6
推荐指数
2
解决办法
2075
查看次数

我的应用程序因非公共API而被拒绝

Apple提供的反馈是:您的应用使用或引用了以下非公共API:

  • " init:"

App Store上不允许使用非公共API,因为如果这些API发生变化,可能会导致糟糕的用户体验.

让我最困惑的是"init:",我的意思是,"init:"有什么问题?我们不能使用"init:"?更重要的是,当我们使用非公共API时,Xcode会有什么变暖吗?我可以找到这些非公共API吗?

objective-c app-store appstore-approval ios ios10

5
推荐指数
1
解决办法
229
查看次数

如何在iOS10上跳转到系统设置的位置服务?

在我问这个问题之前,我试过了:

  1. 使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Privacy&path=LOCATION"]];它在iOS8和iOS9上运行良好,但在iOS10上没有任何变化.
  2. 使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];它在iOS8和iOS9上也能正常工作.但是,在iOS10上,当应用程序跳转到系统设置时,系统设置立即退出.
  3. 使用[[UIApplication sharedApplication]openURL:url options:@{}completionHandler:nil];它在iOS8和iOS9上崩溃,同样,在iOS10上立即退出.

问题是我们的应用程序可以跳转到iOS10上的系统设置吗?如果是的话.[[UIApplication sharedApplication]openURL:url options:@{}completionHandler:nil];如何options?这意味着什么?我们必须为此代码options

xcode objective-c ios

5
推荐指数
3
解决办法
7462
查看次数

如何判断UIScrollView的方向是否会滚动?

注意:我的问题是scrollView的方向滚动,而不是滚动.也就是说,当用户滚动scrollView时,我们可以在scrollView开始滚动之前获取scrollView的方向滚动吗?

有什么想法吗?先谢谢.

objective-c uiscrollview ios

5
推荐指数
1
解决办法
775
查看次数

我们何时应该将弱自我变成强自我?

我知道当我们使用块时,我们应该使用weakSelf来避免保留周期。但是我看到有时在块中有一个strongSelf。

让我感到困惑的是:

  1. 为什么必须将弱自我变成强自我?
  2. 如果我们不将weakSelfSelf更改为strongSelf,将会发生什么可怕的事情?
  3. 我们什么时候应该将弱自我变成强自我?

希望有人能给出一个确切的例子。

提前致谢。

block objective-c

4
推荐指数
2
解决办法
2734
查看次数

Block没有用typeof捕捉自己,为什么?

为了这:

self.block = ^{
    self.view.backgroundColor = [UIColor greenColor];
};
Run Code Online (Sandbox Code Playgroud)

显然有一个保留周期。

但是,有没有保留周期如果self是在typeof

__weak typeof(self) weakSelf = self;
self.block = ^{
    __strong typeof(self) strongSelf = weakSelf;
    strongSelf.view.backgroundColor = [UIColor greenColor];
};
Run Code Online (Sandbox Code Playgroud)

自我的dealloc叫做即使self是在block.That手段块没有捕捉到self这里。

为什么?

objective-c objective-c-blocks

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

当只有一个单元格时,单元格位于集合视图的中心

我想从左到右布局单元格。所以我使用UICollectionViewFlowLayout

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
// use this for let cell width fit for label width
layout.estimatedItemSize = CGSizeMake(80, 30);
self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
Run Code Online (Sandbox Code Playgroud)

单元格的宽度适合标签的宽度:

// cell code
@implementation CQGoodsSearchCell

- (void)setupUI {
    self.contentView.layer.cornerRadius = 15;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.backgroundColor = [UIColor colorWithRed:1.00 green:1.00 blue:1.00 alpha:1.00];

    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.font = [UIFont systemFontOfSize:15];
    self.nameLabel.textColor = [UIColor colorWithRed:0.18 green:0.18 blue:0.18 alpha:1.00];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.top.bottom.mas_offset(0);
        make.left.mas_offset(10);
        make.right.mas_offset(-10);
    }];
} …
Run Code Online (Sandbox Code Playgroud)

objective-c ios autolayout uicollectionview

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

如何获取StatefulWidget的状态?

我是 flutter 的新手,获取 StatefulWidget 状态的方式是向 widget 添加状态属性,例如:

// ignore: must_be_immutable
class _CustomContainer extends StatefulWidget {
  _CustomContainer({Key key}) : super(key: key);

  @override
  __CustomContainerState createState() {
    state = __CustomContainerState();
    return state;
  }

  __CustomContainerState state;

  void changeColor() {
    if (state == null) return;
    // call state's function
    this.state.changeColor();
  }
}

class __CustomContainerState extends State<_CustomContainer> {
  var bgColor = Colors.red;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 200,
      height: 200,
      color: bgColor,
    );
  }

  void changeColor() {
    setState(() {
      bgColor = Colors.blue;
    }); …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

如何判断iPhone是iPhoneX系列?

有没有办法判断iPhone是iPhoneX系列(iPhone X XR XS XSmax)?

我的方式是:

#define iPhoneXSeries (([[UIApplication sharedApplication] statusBarFrame].size.height == 44.0f) ? (YES):(NO))
Run Code Online (Sandbox Code Playgroud)

有什么隐患吗?

还是有更好的方法吗?

objective-c ios

0
推荐指数
1
解决办法
561
查看次数