小编She*_*khu的帖子

怎么识别手指是在镜头上还是不在android?

我正在尝试使用Android设备中的相机测量Heart Beat.

据我所知,将指尖放在相机镜头上并观察相机中帧的变化.我在这里尝试过这个应用程序,但它似乎不正确.

camera android heartbeat beat-detection

13
推荐指数
1
解决办法
1443
查看次数

调用自定义视图时,UIButton无法单击

我是iPhone开发的新手,我需要帮助理解下面的内容,因为我可以使用以下内容创建newView

UIView *newView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 30)]; 
newView.backgroundColor=[UIColor clearColor];
UIButton *newViewBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];


newViewBtn.frame = CGRectMake(newView.frame.origin.x+5,
                            newView.frame.origin.y+5,60,20);
[newView addSubview:newViewBtn];
[self.view addSubview:newView]; 
Run Code Online (Sandbox Code Playgroud)

上面的代码工作没有任何问题.但是当我尝试使用以下内容创建视图时,视图创建正常,但视图上的按钮不可单击.

int randNumX = arc4random() % 150;
int randNumY = arc4random() % 200;
UIView newView=[[UIView alloc]init];
newView.frame =CGRectMake(randNumX, randNumY, 80, 30);

newView.backgroundColor=[UIColor clearColor];

UIButton *newViewBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
newViewBtn.frame  = CGRectMake(newView.frame.origin.x+5
                         ,newView.frame.origin.y+5,60,20);
[newView addSubview:newViewBtn];
[self.view addSubview:newView];
Run Code Online (Sandbox Code Playgroud)

如果更改以下代码,还有另一种情况

 newViewBtn.frame = CGRectMake(newView.frame.origin.x+5
                          ,newView.frame.origin.y+5,60,20);
Run Code Online (Sandbox Code Playgroud)

使用以下代码崩溃的应用程序

 newViewBtn.frame =CGRectMake(randNumX+5,randNumY+5,60,20);
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,提前感谢.

我已经添加了以下代码

     newViewBtn addTarget:self action:@selector(btnclick:)forControlEvents:UIControlEventTouchUpInside];

     -(void)btnclick:(id)sender
     {
       //my code
     }
Run Code Online (Sandbox Code Playgroud)

它在第一种情况下工作:

我主要关心的是当newView被绘制时,为什么这个视图上的按钮不可点击

user-interaction uibutton uiviewcontroller ios

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

如何在NSUserDefault中设置实体

我们可以将核心日期实体存储到NSUser NSUserDefault中.我正在尝试保存实体.但它在我想要使用的点返回null.但是如果我尝试保存实体属性.it返回阀门.

下面是我的代码示例,如果我使用以下来保存实体

    MyEntity *newEntity = [self.fetchController objectAtIndexPath:indexPath];
    [[NSUserDefaults standardUserDefaults]setObject:newEntity forKey:@"Act"];
Run Code Online (Sandbox Code Playgroud)

并使用以下内容获取实体.结果为null.

     MyEntity *entityAtOtherClass =[[NSUserDefaults standardUserDefaults] valueForKey:@"Act"];
Run Code Online (Sandbox Code Playgroud)

好像我试图存储实体属性说一些字符串,然后我能够获得此实体对象的值.

[[NSUserDefaults standardUserDefaults]setValue:newEntity.name forKey:@"Activity"];
Run Code Online (Sandbox Code Playgroud)

core-data objective-c nsuserdefaults ios

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

如何在iOS上获得上个月的第一天

我正在使用日历应用程序,当我导航到下个月时,它工作正常,因为我能够获得该月的最后一天,并且从那里我可以获得下个月的第一天.但是当我导航到之前的一个月我无法得到上个月的第一天.有没有办法获得上个月的第一天.

iphone ios

-1
推荐指数
1
解决办法
1429
查看次数