小编Myx*_*tic的帖子

键盘卡在ios 13模拟器中

我一直在尝试使我的项目与新的Xcode 11协同工作。除在某些情况下(当我在模拟器上运行我的应用程序(iPhone 11 Pro Max)时,在单击EditTexts后该应用程序冻结)之外,其他所有操作均正常进行。我使用该应用几次后,就会发生这种情况。如果清除模拟器内存​​并重新启动,则一切正常。

我仅使用EditText创建了一个视图控制器,并且能够复制冻结的模拟器。有时在启动软键盘之前冻结,有时在显示之后冻结。我仍然可以终止该应用程序并通过Xcode重新运行它,但是除非我在模拟器上进行硬件重置,否则每次都会冻结。

我只是担心这是否也会在设备上发生?有人面对过吗?

编辑:只是添加。发生这种情况时,我尝试使用消息传递应用程序,并且在那里发生了同样的事情。

ios swift xcode11

36
推荐指数
6
解决办法
2858
查看次数

在Swift中显示和关闭模态视图控制器

当按下按钮时,我想通过使用模态过渡样式在两个视图控制器之间进行切换CoverVertical,然后将其关闭.有关于如何在目标C中执行此操作的信息,但在Swift中找不到任何好的信息.到目前为止我已经做到了这一点,但我不认为这是正确的:

 @IBAction func insertStatus(sender: UIButton) {

         var StatusVC: StatusViewController = StatusViewController()
    var modalStyle: UIModalTransitionStyle = UIModalTransitionStyle.CoverVertical
    StatusVC.modalTransitionStyle = modalStyle
    self.presentViewController(StatusVC, animated: true, completion: nil)

    }
Run Code Online (Sandbox Code Playgroud)

我这样使用的解雇也不起作用:

@IBAction func statusSaved(sender: UIBarButtonItem) {

        self.dismissViewControllerAnimated(false, completion: { () -> Void in
            let usersVC: UsersViewController = self.storyboard?.instantiateViewControllerWithIdentifier("UsersViewController") as UsersViewController
       })
    }
Run Code Online (Sandbox Code Playgroud)

ios segue swift

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

显示应用程序的构建日期

我能够在模拟器中显示我的应用程序的构建日期,但每当我存档应用程序并将其上传到TestFlight,然后将其安装在设备上时,构建日期都不会显示.

这是我正在做的显示构建日期.

首先,我将CFBuildDate作为字符串添加到myproject-info.plist中

接下来,我将以下脚本添加到Edit Scheme - > Build - > Pre-Actions - > Run Script Action:

infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
builddate=`date`
if [[ -n "$builddate" ]]; then
/usr/libexec/PlistBuddy -c "Add :CFBuildDate $builddate" ${infoplist}
/usr/libexec/PlistBuddy -c "Set :CFBuildDate $builddate" ${infoplist}
fi
Run Code Online (Sandbox Code Playgroud)

最后,使用以下代码从plist文件中获取构建日期:

NSString *build_date = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];
Run Code Online (Sandbox Code Playgroud)

这会在模拟器中显示构建日期(虽然偶尔也没有),但是当通过TestFlight部署应用程序时,构建日期永远不会显示.有任何想法吗 ?

提前致谢.

xcode build objective-c ios

15
推荐指数
5
解决办法
6903
查看次数

如何计算ActiveRecord .group查询的结果?链接.count返回一个哈希值

我可以使用以下内容:

User.where("zip_code = '48104'").group('users.id').count
Run Code Online (Sandbox Code Playgroud)

得到如下的哈希:

{195=>1, 106=>1, 120=>1, 227=>1, 247=>1, 264=>1, 410=>1}
Run Code Online (Sandbox Code Playgroud)

有没有办法计算这些哈希值,只返回7,而不是上面的结果?

我知道在上面的场景中这没有意义,我可以通过不使用group子句来实现.但是我正在研究一个更复杂的查询,我需要实现它.提前致谢.

activerecord ruby-on-rails

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

映射到哈希的键

我正在使用名为my_hash的哈希:

{"2011-02-01 00:00:00+00"=>816, "2011-01-01 00:00:00+00"=>58, "2011-03-01 00:00:00+00"=>241}
Run Code Online (Sandbox Code Playgroud)

首先,我尝试解析my_hash中的所有键(有时候).

my_hash.keys.sort.each do |key|
  parsed_keys << Date.parse(key).to_s
end 
Run Code Online (Sandbox Code Playgroud)

这给了我这个:

["2011-01-01", "2011-02-01", "2011-03-01"]
Run Code Online (Sandbox Code Playgroud)

于是,我尝试映射parsed_keys回的键my_hash:

Hash[my_hash.map {|k,v| [parsed_keys[k], v]}]
Run Code Online (Sandbox Code Playgroud)

但是返回以下错误:

TypeError: can't convert String into Integer
Run Code Online (Sandbox Code Playgroud)

我该如何映射parsed_keys回的键my_hash

我的目标是在所有键的末尾摆脱"00:00:00 + 00".

ruby-on-rails hashmap

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

Ruby on Rails - 动态SQL查询

我在我的一个控制器中执行以下原始sql查询:

active_users_query = <<-SQL 
       SELECT count(DISTINCT patients.id)
       FROM public.patients, public.subscriptions, public.users, public.calendar_days
       WHERE patients.user_id = users.id 
       AND patients.id = calendar_days.patient_id 
       AND subscriptions.user_id = patients.user_id 
       AND (date_trunc('day',patients.last_sync) > current_date - interval '30 days' 
       OR date_trunc('day', calendar_days.created_at) > current_date - interval '30 days' 
       OR date_trunc('day',users.current_sign_in_at) > current_date - interval '30 days') 
       AND subscriptions.code_id = 2  
SQL
Run Code Online (Sandbox Code Playgroud)

有没有办法可以在这个查询的最后一行添加一些RoR代码来动态生成code_id?

像这样的东西:

AND subscriptions.code_id = '@subscription.code'
Run Code Online (Sandbox Code Playgroud)

sql postgresql activerecord ruby-on-rails

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

Git推不起作用

我正在与两个分支测试主要工作.

所以,在主要分支上,我做了:

git merge test
Run Code Online (Sandbox Code Playgroud)

一切都很顺利.所有的变化都合并了.

然后把它推到遥控,我做了:

git push
Run Code Online (Sandbox Code Playgroud)

但它似乎没有做任何事,它说:

Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:Company/My-App.git
b878c9d..0dc7fbe  main -> main
Run Code Online (Sandbox Code Playgroud)

我不认为如果推进确实很好的话,它应该在上面显示为零.

我该如何推动我的分支?

github

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

应用程序终止后收到位置更新

我需要一直跟踪用户位置(但不要耗尽电池).我理解终止应用程序后获取更新的唯一方法是使用startMonitoringSignificantLocationChanges.

从关于startMonitoringSignificantLocationChanges的Apple位置感知编程指南:

如果您启动此服务并且您的应用程序随后终止,则系统会在新事件到达时自动将应用程序重新启动到后台.在这种情况下,传递给应用程序的选项字典:didFinishLaunchingWithOptions:应用程序委托的方法包含密钥UIApplicationLaunchOptionsLocationKey,以指示您的应用程序是由于位置事件而启动的.重新启动后,您仍必须配置位置管理器对象并调用此方法以继续接收位置事件.重新启动位置服务时,会立即将当前事件传递给您的代理.此外,即使在启动位置服务之前,也会使用最新的位置对象填充位置管理器对象的位置属性.

如果有人可以在代码中演示(举例)我应该使用哪种方法,我会很高兴

在下面的代码中,我要说: - 在appdelegate启动位置管理器,它可以监控signinficant监视器更改更新和启动日期. - 在didUpdateToLocation中我正在调用stopupdating - 在didFinishLaunchingWithOptions中,当我检查我是否有UIApplicationLaunchOptionsLocationKey以便知道我是否在后台并且由于显着的监视器位置更新而启动. - 如果是这样,我再次调用startMonitoringSignificantLocationChanges(不知道为什么......)并开始一个UIBackgeoundTaskIdentifier来调用startupdating方法.

LocationController.m : 
+ (LocationController*)sharedInstance {
    @synchronized(self) {
        if (sharedCLDelegate == nil) {
            [[self alloc] init];
        }
    }
    return sharedCLDelegate;
}

- (id)init
{
    self = [super init];
    if (self != nil) {
        self.locationManager = [[[CLLocationManager alloc] init] autorelease];
        self.locationManager.delegate = self;
        self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
        [self.locationManager startUpdatingLocation];
        [self.locationManager startMonitoringSignificantLocationChanges];

    }
    return self;
}
- (void) startMonitoringSignificantLocationChanges
{
    [self.locationManager startMonitoringSignificantLocationChanges];
}
- (void) stopMonitoringSignificantLocationChanges
{
    [self.locationManager stopMonitoringSignificantLocationChanges];
} …
Run Code Online (Sandbox Code Playgroud)

cllocationmanager cllocation

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

调试rake任务

我添加debuggerrequire 'ruby-debug'在我的任务中调试它.

当我从控制台运行我的任务时,它确实击中了debugger,但是不让我检查任何变量.例如,如果我的任务中有一行:

my_var = 1 + 2
Run Code Online (Sandbox Code Playgroud)

我输入my_var或者my_var.inspect,在调试时,它说:

*** Unknown command: "my_var".  Try "help".
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

rake ruby-on-rails ruby-debug

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

在 &lt;th&gt; 元素内添加 &lt;th&gt; 元素

我有一个 html 表格,其中一个标题跨越 2 列。如何向两列中的每一列添加子标题?

例如,在附图中,我希望“联系人”列的相应列有子标题“电话”和“地址”。

在此输入图像描述

html html-table

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

无法在cellForRowAtIndexPath中获取单元格框架或约束

问题

我试图根据某些条件调整放置在UITableViewCell内的UIButton的一些约束.

我在datasource方法中这样做cellForRowAtIndexPath.但是,看起来我的单元格的框架总是回来(0, 0, 0, 0),这意味着我无法获得任何子视图的约束来调整它们,除非我滚动.

我曾经尝试过什么

创建并上传了一个简单的项目,试图找出问题所在.以下代码来自cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    TestCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TestCell"];
    cell.label.text = [NSString stringWithFormat:@"%lu", indexPath.row];

    NSLog(@"CELL FRAME: %f, INDEXPATH: %lu, CONSTRAINTS: %lu", CGRectGetWidth(cell.frame), indexPath.row, cell.label.constraints.count);

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

结果

当我运行项目时,我看到以下日志:

CELL FRAME WIDTH: 0.000000, INDEXPATH: 0, CONSTRAINTS: 0
Run Code Online (Sandbox Code Playgroud)

但是,一旦我滚动,我开始看到类似的东西:

CELL FRAME WIDTH: 320.000000, INDEXPATH: 7, CONSTRAINTS: 2
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?如何调整单元格子视图的约束来调整它们,而不必先滚动?

提前致谢.

objective-c uitableview ios autolayout

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

跟踪滑动

有没有办法让我检查滑动手势是否通过屏幕上的特定点?

我想要实现这样的事情:

http://screenshots.en.sftcdn.net/en/scrn/3337000/3337188/dot-lock-03-356x535.jpg

如果跟踪滑动的方法不适合实现这一点,请告诉我.

谢谢.

cocoa-touch core-graphics objective-c cocos2d-iphone ios

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

检查复杂JSON响应中的空键

我无法检查我的一个键是否为空.

以下是我正在使用的解析JSON响应:

案例1(关键'标签'不为空)

{
height = 480;
pid = "a@bsioihf93u420934";
tags =     (
            {
        attributes =             {
            mood =                 {
                confidence = 42;
                value = happy;
            };
            smiling =                 {
                confidence = 52;
                value = false;
            };
        };
        center =             {
            x = "49.86";
            y = "60.52";
        };
        confirmed = 0;
        width = "50.28";
    }
);
url = "http://abc/efg/hijk/lmnop.jpg";
width = 360;
}
Run Code Online (Sandbox Code Playgroud)

有时候响应如下所示:

案例2(关键'标签'为空)

{
height = 480;
pid = "a@bsioihf93u420934";
tags =     (
);
url = "http://abc/efg/hijk/lmnop.jpg";
width …
Run Code Online (Sandbox Code Playgroud)

xcode json objective-c ios

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