小编mar*_*rko的帖子

硬件键盘输入失去焦点

我在TabHost中有一个片段,里面有多个文本字段.虚拟键盘可以很好地使用inputType设置输入文本,但硬件键盘(在Droid,Droid 2等上)不起作用.

从我的测试开始,一旦你开始在硬件键盘上打字,EditText失去了焦点,"打字"似乎在应用程序的其他地方.我在下面尝试了两种配置:

<EditText
     android:id="@+id/editTextPlusFat"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight="0.15"
     android:background="@drawable/textfield_default_holo_light"
     android:digits="0123456789."
     android:ems="10"
     android:hint="@string/str_CalcHintFat"
     android:inputType="number" >
Run Code Online (Sandbox Code Playgroud)

<EditText
     android:id="@+id/editTextPlusFat"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight="0.15"
     android:background="@drawable/textfield_default_holo_light"
     android:ems="10"
     android:hint="@string/str_CalcHintFat"
     android:inputType="numberDecimal" >
Run Code Online (Sandbox Code Playgroud)

有没有人有任何想法为什么会这样?谢谢.

keyboard android android-edittext

5
推荐指数
2
解决办法
2528
查看次数

在OpenCL中使用内核导致另一个内核

我已经使用API​​的clCreateImage2D编写了卷积图像的代码,用于创建空间,clEnqueueWriteImage用于写入设备,read_imageui用于读取内核中的图像,write_imageui用于将图像写回主机.

现在我想使用卷积内核的结果,该内核指向另一个内核参数中的缓冲区.没有将结果移回主机和向前移动到设备.这是可能的.

如果结果来回移动......我认为这将是昂贵的.

在这方面的任何帮助将是非常宝贵的.

kernel opencl

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

一个控制器中的两个表视图

所以我试图在一个视图中制作两个tableview,我遇到了一些麻烦.我已经阅读了一些关于如何做的其他回复,但它们并没有完全帮助我.

在我的.h文件中我做了两个网点为两个视图打电话给他们myFirstViewText,并mySecondViewTex

所以在我的m文件中 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

我希望能够在每个不同的控制器中打印出单独的值,我不太确定,因为你只返回1个单元格?

到目前为止我已经完成了这件事

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Rx";
static NSString *CellIdentifier2 = @"allergies";
UITableViewCell *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:CellIdentifier];
UITableViewCell *cell2 = [tableView dequeueReusableHeaderFooterViewWithIdentifier:CellIdentifier2];
if(!cell){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (!cell2) {
    cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
}
if (tableView == self.myFirstTextView ) {
       cell.textLabel.text = @"HI JAZZY";//[RxDict objectAtIndex:indexPath.row];
}
if (tableView == self.mySecondTextView) {
      cell.textLabel.text = @"BYE JAZZY";//[RxDict objectAtIndex:indexPath.row]; …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios

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

Android AudioRecord - 使用短数组还是字节数组?

我正在开发一个记录音频的安卓应用程序。为了获得最佳音频质量,最好short在阅读时使用s缓冲区?

//aRecorder.read(shortBuffer, 0, shortBuffer.length);
aRecorder.read(byteBuffer, 0, byteBuffer.length);
Run Code Online (Sandbox Code Playgroud)

使用short[]与使用byte[]和考虑来自 2bytes(byteBuf[i]byteBuf[i+1])的样本不同?如果我使用short[],无论如何我都必须将其转换为将其ByteBuffer写入文件。

我问这个是因为我想知道如果我切换到shorts 的缓冲区,我的录音会更准确吗?例如,shortBuffer[0]包含了相同的信息byteBuffer[0]byteBuffer[1]

录音可以是 16 位 PCM 或 8 位 PCM(用户可以选择采样率、通道数、PCM 16 或 8 等)

我必须提到输出文件将采用 WAV 格式。

audio android audio-recording audiorecord android-audiorecord

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

Empty C++ 11初始化列表导致带有一个默认构造对象的容器

下面的代码使用空的C + 11样式初始化程序.运行时,结果是std::vector包含一个项目,该项目似乎是默认构造的.

这显然是一个人为的案例,并且有更好的方法来构建空向量.Nonetheles,这种行为是违反直觉的.这是编译器/ c ++运行时库的错误吗?

我怀疑其中一个std::vector其他构造函数实际上是在这里调用的.

#include <iostream>
#include <memory>
#include <vector>

int main(int argc, const char * argv[])
{
    typedef std::vector<std::shared_ptr<int>> Container;

    Container c{{}};

    std::cout << "Vector size is: " << c.size() << std::endl;

    for (auto item: c)
    {
        std::cout << "Item: " << item.get() << std::endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:

Vector size is: 1
Item: 0x0
Program ended with exit code: 0
Run Code Online (Sandbox Code Playgroud)

编译:

$ clang  --version
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM …
Run Code Online (Sandbox Code Playgroud)

c++11

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

"重复符号"链接器错误没有明显原因

Duplicate symbols在链接我的项目时看到了.我不知道这意味着什么,也不知道如何解决它,所以任何帮助都将不胜感激.

因为shipNameText似乎是错误的来源,所以我在这里使用它:在.h中:

@property (strong,nonatomic)IBOutlet  UILabel *shipNameText;
Run Code Online (Sandbox Code Playgroud)

在.m

@interface boatInfoViewController ()

@end

@implementation boatInfoViewController
@synthesize shipNameText, shipSizeText;


- (void)viewDidLoad
{
    [super viewDidLoad];
    NSUserDefaults *shipName = [NSUserDefaults standardUserDefaults];
    NSUserDefaults *shipSize = [NSUserDefaults standardUserDefaults];
    NSString *name = [[NSUserDefaults standardUserDefaults]
                                 objectForKey:@"shipName"];
    NSString *size = [[NSUserDefaults standardUserDefaults]
                      objectForKey:@"shipSize"];
    shipNameText.text = name;
    shipSizeText.text = size;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

xcode compiler-errors objective-c ios

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

UICollectionView Cell nib未加载

我正在使用一个UICollectionViewFlowLayout允许重新排序单元格的自定义子类.源代码在这里.

我遇到的问题是,尽管注册并使用正确的标识符,我为Collection View创建的nib文件仍未加载.以下是相关的代码段.

这是在视图控制器.m文件中:

- (void)loadView
{
    self.reorderLayout = [[LXReorderableCollectionViewFlowLayout alloc] init];

    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero
                                             collectionViewLayout:self.reorderLayout];

    UINib *nib = [UINib nibWithNibName:@"CatagoryViewCell" bundle:nil];
    [self.collectionView registerNib:nib forCellWithReuseIdentifier:@"CatagoryViewCellID"];

    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    Catagory *c = [[[CatagoryStore defaultStore] allCatagories]
                   objectAtIndex:[indexPath item]];

    CatagoryViewCell *cell = (CatagoryViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"CatagoryViewCellID" forIndexPath:indexPath];

    [cell setController:self];

    [[cell nameLabel] setText:c.title];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

这是我引用笔尖的唯一两个地方.

这是单元格笔尖: 在此输入图像描述

这就是它在模拟器和设备中的样子:

在此输入图像描述

我尝试使用类似的代码和原始UICollectionViewFlowLayout类,它工作正常.非常感谢任何见解!

iphone xcode objective-c uicollectionview uicollectionviewcell

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

iOS:使用Swift2删除.DocumentDirectory中的文件

我有一个项目,我正在将数据保存为PDF.这个代码是:

// Save PDF Data

let recipeItemName = nameTextField.text

let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]

pdfData.writeToFile("\(documentsPath)/\(recipeFileName).pdf", atomically: true)
Run Code Online (Sandbox Code Playgroud)

我能够UITableView在另一个文件中单独查看文件ViewController.当用户滑动时,UITableViewCell我希望它也从中删除该项目.DocumentDirectory.我的UITableView删除代码是:

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {

    if editingStyle == .Delete {

        // Delete the row from the data source

        savedPDFFiles.removeAtIndex(indexPath.row)

        // Delete actual row

        tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)


        // Deletion code for deleting from .DocumentDirectory here???


    } else if editingStyle == .Insert {

        // Create a new instance …
Run Code Online (Sandbox Code Playgroud)

uitableview delete-file ios swift2

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

在iOS设备上有"优化"类型吗?

在这里,我只是编写了一些处理整数值-24/+ 24的代码,并且我让我的方法返回一个int ...我想我自己 - 在这种情况下我真的应该使用短路吗?我知道它可能在那些记忆力为48k的那一天很重要 - 但在今天的现代世界中它真的重要吗?

即使我知道我的数字会非常小,只是"快乐"就可以了吗?

arm objective-c ios

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

pcap_lookupdev undefined

我正在为OSX 10.8开发.我刚刚libpcap通过MacPorts 安装并尝试运行一个简单的设备猎人(下)

#include <stdio.h>
#include <pcap.h>

int main(int argc,char *argv[])
{
    char *dev, errbuf[PCAP_ERRBUF_SIZE];

    dev = pcap_lookupdev(errbuf);
    if(dev == NULL)
    {
        fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
        return(2);
    }

    printf("Device %s\n", dev);
    return(0);
}
Run Code Online (Sandbox Code Playgroud)

在尝试使用g ++编译时,我得到:

    Undefined symbols for architecture x86_64:
  "_pcap_lookupdev", referenced from:
      _main in ccIMp1m2.o
Run Code Online (Sandbox Code Playgroud)

任何有用的建议,所以我真的可以开始学习这些东西将是伟大的!我用谷歌搜索了10-15分钟,但在我的设置中找不到我的特定问题.

c++ sniffing pcap network-security

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

无法分配CUDA共享内存

我正在编写使用共享内存的CUDA内核代码,但是很难声明共享内存变量.

当我尝试静态分配多个共享内存时,会发生这种情况,如下所示.

__global__
void kernel_func(float *global_matrix) {
    __shared__ float sm_mat1[4][4];
    __shared__ float sm_mat2[6][6];
    __shared__ float sm_mat3[3][3][3];

    if ( blockIdx.x==0 && blockIdx.y==0 && theradIdx.x==0 && threadIdx.y==0 )
        printf("sizeof(sm_mat1)=%d, sizeof(sm_mat2)=%d, sizeof(sm_mat3)=%d.\n",
                    sizeof(sm_mat1), sizeof(sm_mat2), sizeof(sm_mat3));

    ...
}
Run Code Online (Sandbox Code Playgroud)

但是,当我执行时,它输出奇怪的消息如下.sizeof(sm_mat1)= 64,sizeof(sm_mat2)= 0,sizeof(sm_mat3)= 128

似乎没有分配第二矩阵,第三矩阵被分配为第二.实际上,访问第二个矩阵不能正常工作.(无法读/写数据).

我正在使用GTX 480和cuda2.0.(我正在使用编译选项-arch = sm_20打印消息).

有没有人有任何想法?

memory cuda

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

预期标识符或'('编译Objective-C时

所以我试图制作这个相机应用程序,但每次我尝试运行它,它会说"预期标识符或'('.我得到其中两个错误.其中一个正好在下面 - (IBAction)takePhoto:(UIButton *)sender;,一个在- (IBAction)selectPhoto:(UIButton *)sender; 谢谢之下

#import <UIKit/UIKit.h>

@interface APPViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

@property (strong, nonatomic) IBOutlet UIImageView *ImageView;


- (IBAction)takePhoto:(UIButton *)sender;
{
 UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType =UIImagePickerControllerSourceTypeCamera;

    [self presentViewController:picker animated:YES completion:NULL];
}

- (IBAction)selectPhoto:(UIButton *)sender;
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];
}
@end
Run Code Online (Sandbox Code Playgroud)

objective-c

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