问题列表 - 第42456页

从UIAlertView获取文本

我正在尝试从警报视图中获取文本并将其添加到我的可变数组中以在表视图中列出.我意识到几个月前发布了类似的问题,但我不明白如何利用给定的答案.

-(IBAction)insert {
    UIAlertView* dialog = [[UIAlertView alloc] init];
    [dialog setDelegate:self];
    [dialog setTitle:@"Enter Name"];
    [dialog setMessage:@" "];
    [dialog addButtonWithTitle:@"Cancel"];
    [dialog addButtonWithTitle:@"OK"];

    UITextField *nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
    [nameField setBackgroundColor:[UIColor whiteColor]];
    [dialog addSubview:nameField];
    [dialog show];

    [data addObject:[nameField text]];
    [mainTableView reloadData];
Run Code Online (Sandbox Code Playgroud)

然而,我的应用程序崩溃,因为它说我试图在索引0处插入一个零对象.我做错了什么?

编辑:好吧我想我错过了处理alertview的方法.所以我发现了这个:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSString *buttonTitle=[alertView buttonTitleAtIndex:buttonIndex];
    if([buttonTitle isEqualToString:@"Cancel"]) {
        return;
    }
    else if([buttonTitle isEqualToString:@"Ok"]) {
        [data addObject:nameField.text];

    }
Run Code Online (Sandbox Code Playgroud)

现在我只需要连接各个部分,但不知道如何.

iphone objective-c uialertview

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

将XAML PathGeometry转换为WPF PathGeometry

我想要由LineSegment组成的PathGeometry.

所以,我使用第一个代码,但它是错误的.

PathGeometry temp = (PathGeometry)Geometry.Parse(
            "<PathGeometry.Figures>" +
                "<PathFigure StartPoint=\"193.5,283.5\" IsClosed=\"True\">" +
                    "<PathFigure.Segments>" +
                        "<LineSegment Point=\"418.5,283.5\" />" +
                        "<LineSegment Point=\"418.5,508.5\" />" +
                        "<LineSegment Point=\"193.5,508.5\" />" +
                        "<LineSegment Point=\"193.5,283.5\" />" +
                    "</PathFigure.Segments>" +
                "</PathFigure>" +
            "</PathGeometry.Figures>");
Run Code Online (Sandbox Code Playgroud)

如果我使用第二个代码,它不是错误,但它不包含LineSegment.结果将是PolyLineSegment,但我想要LineSegment.

PathGeometry temp = (PathGeometry)Geometry.Parse(
                "M29,329L30,331L31,334L33,336L34,338L36,341L38,343L39,345L41,348L44,352L46,353L47,355L48,356L49,357L49,357L50,358L50,358L51,357L50,356L51,354L51,350L53,342L54,334L58,320L60,315L61,311L63,308L63,306L64,304L65,303L65,302L66,301L66,301L66,301L66,301L66,301L66,301L66,301");
Run Code Online (Sandbox Code Playgroud)

如何将XAML PathGeometry转换为WPF PathGeometry?

谢谢

c# wpf xaml pathgeometry

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

boost :: ~shared_ptr如何工作?

在阅读"超越C++标准库:Boost简介"时,我得到了一个非常有趣的例子:

class A  
{  
public:  
    virtual void sing()=0;  
protected:  
    virtual ~A() {};  
};

class B : public A
{  
public:  
    virtual void sing(  )  
    {  
       std::cout << "Do re mi fa so la"<<std::endl;;  
    }  
};  
Run Code Online (Sandbox Code Playgroud)

我做了一些测试:

int main()
{  

//1  
std::auto_ptr<A> a(new B); //will not compile ,error: ‘virtual A::~A()’ is protected

//2
A *pa = new B;
delete pa;  //will not compile ,error: ‘virtual A::~A()’ is protected
delete (dynamic_cast<B*>(pa)); //ok

//3 
boost::shared_ptr<A> a(new B);//ok

}
Run Code Online (Sandbox Code Playgroud)

我在这里很好奇的是~hared_ptr是如何工作的?它如何推导派生类B?

谢谢你的帮助!

谢谢大家,我写了一个关于~share_ptr如何工作的简单示例

class sp_counted_base …
Run Code Online (Sandbox Code Playgroud)

c++ boost shared-ptr

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

检查iOS应用程序的长期内存使用情况

仪器可以用来检查应用程序的短期内存使用情况,但有没有办法检查你的iOS应用程序的内存消耗,当它被大量使用并在iOS 4上预见/后台时,比如一周?

iphone memory-management ios

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

如何获取任何网址或网页的Google缓存时限?

在我的项目中,我需要将Google缓存时代添加为重要信息.我尝试搜索Google缓存时代的来源,即Google上次重新索引所列页面的天数.

我在哪里可以获得Google缓存时代?

html url hyperlink web-scraping

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

使用简单的方法安全地擦除文件?

可能重复:
C# - 永久删除文件

你好,

我正在使用C#.NET Framework 2.0.我有一个与文件粉碎有关的问题.

我的目标操作系统是Windows 7,Windows Vista和Windows XP.可能是Windows Server 2003或2008,但我猜它们应该与前三个相同.

我的目标是安全地删除文件.

我不相信使用File.Delete是安全的.我在某处读到,当您删除文件时,操作系统只是标记要删除的原始硬盘数据 - 数据根本不会被删除.这就是为什么存在这么多工作方法来恢复所谓的"已删除"文件的原因.我也读过,这就是覆盖文件更有用的原因,因为那时磁盘上的数据实际上必须要改变.这是真的?这通常需要什么?

如果是这样,我相信我可以简单地将文件写入1和0的几次.

我读过:http : //www.codeproject.com/KB/files/NShred.aspx http://blogs.computerworld.com/node/5756 http://blogs.computerworld.com/node/5687 安全删除C#.NET中的文件

c# security aes sha512

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

R中模型矩阵中因子的所有级别

我有一个data.frame数字和因子变量组成,如下所示.

testFrame <- data.frame(First=sample(1:10, 20, replace=T),
           Second=sample(1:20, 20, replace=T), Third=sample(1:10, 20, replace=T),
           Fourth=rep(c("Alice","Bob","Charlie","David"), 5),
           Fifth=rep(c("Edward","Frank","Georgia","Hank","Isaac"),4))
Run Code Online (Sandbox Code Playgroud)

我想构建一个matrix为该因子分配虚拟变量并单独保留数值变量.

model.matrix(~ First + Second + Third + Fourth + Fifth, data=testFrame)
Run Code Online (Sandbox Code Playgroud)

正如预期的那样,在运行时会将lm每个因子的一个级别作为参考级别.但是,我想为matrix所有因素的每个级别构建一个带有虚拟/指示变量的变量.我正在建立这个矩阵,glmnet所以我不担心多重共线性.

有没有办法model.matrix为每个级别的因子创建假人?

model r matrix indicator

62
推荐指数
4
解决办法
5万
查看次数

解密错误:Pad块损坏

我有以下代码.

    byte[] input = etInput.getText().toString().getBytes();
    byte[] keyBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 };

    SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");

    Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC");

    // encryption pass
    cipher.init(Cipher.ENCRYPT_MODE, key);

    byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
    int ctLength = cipher.update(input, 0, input.length, cipherText, 0);
    ctLength += cipher.doFinal(cipherText, ctLength);

    cipher.init(Cipher.DECRYPT_MODE, key);
    byte[] plainText = new byte[cipher.getOutputSize(ctLength)];
    int ptLength = cipher.update(cipherText, …
Run Code Online (Sandbox Code Playgroud)

java encryption android

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

如何排除不与另一个表连接的行?

我有两个表,一个有主键,另一个有外键.

我想从主表中提取数据,只有当辅助表没有包含它的密钥的条目时.与简单内部联接相反的排序,仅返回通过该键连接在一起的行.

sql join

70
推荐指数
3
解决办法
9万
查看次数

如何在确定的位置充气视图?

我有一个带有"添加"和"删除"按钮的活动.

"添加按钮"会使视图膨胀,"删除按钮"会删除选定的视图.

当我使用"添加按钮"给视图充气时,它会自动绘制在任何先前的隐藏视图下方.

我想让用户有可能上下移动每个充气的视图,这样他就可以改变它们在屏幕上显示的顺序(在一种拖拽效果中)

+---------------------+     +---------------------+
| +-----------------+ |     | +-----------------+ | 
| |      View 1     | |     | |      View 2     | |  
| +-----------------+ |     | +-----------------+ |
|                     | --> |                     |
| +-----------------+ |     | +-----------------+ |
| |      View 2     | |     | |      View 1     | |
| +-----------------+ |     | +-----------------+ |  
+---------------------+     +---------------------+
Run Code Online (Sandbox Code Playgroud)

是否可以指定每个视图膨胀的"位置"?(例如,低于或高于当前选定的视图?)

如果没有,达到预期效果的最佳方法是什么?

(如果您认为可能有帮助,请随时询问任何代码段)

android drag-and-drop view inflate

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