小编Qui*_*don的帖子

如何在Swift中将TextField添加到UIAlertController

我试图UIAlertController用a表示UITextView.当我添加行:

    //Add text field
    alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
    }        
Run Code Online (Sandbox Code Playgroud)

我收到一个Runtime错误:

致命错误:在展开Optional值时意外发现nil

    let alertController: UIAlertController = UIAlertController(title: "Find image", message: "Search for image", preferredStyle: .Alert)

    //cancel button
    let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
        //cancel code
    }
    alertController.addAction(cancelAction)

    //Create an optional action
    let nextAction: UIAlertAction = UIAlertAction(title: "Search", style: .Default) { action -> Void in
        let text = (alertController.textFields?.first as! UITextField).text
        println("You entered \(text)")
    }
    alertController.addAction(nextAction)

    //Add …
Run Code Online (Sandbox Code Playgroud)

uitextfield ios swift uialertcontroller

83
推荐指数
6
解决办法
7万
查看次数

通过命令行在OS X上编译简单的Hello World程序

我有一个简单的hello world示例,我正在尝试在OS X上编译,命名为hw.cpp:

#include <iostream>
#include <string>
using namespace std;
int main() {
  cout << "Hello world!" << endl;
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我想用它编译它gcc,但我没有成功.我还想听听其他选项,比如使用Xcode?

c++ macos xcode

81
推荐指数
4
解决办法
14万
查看次数

类型脚本中的数组

我发现很难在打字稿中声明数组并访问它.

下面是为我工作的代码

class Book {
    public BookId: number;
    public Title: string;
    public Author: string;
    public Price: number;
    public Description: string;
}

class dataservice {
    getproducts() {
        var bk = new Book();
        bk.Author = "vamsee";
        bk.BookId = 1;
        var bks: Book[] = [bk,bk];

        return bks.length;
    }
}

var ds = new dataservice();
var button = document.createElement('button');

button.onclick = function () {     
    alert(ds.getproducts().toString());
}

document.body.appendChild(button);
Run Code Online (Sandbox Code Playgroud)

当我更改我的代码时,它尝试为数组项分配值时失败.

var bks: Book[] = new Book[2];
bks[0].Author = "vamsee";
bks[0].BookId = 1;
return bks.length;
Run Code Online (Sandbox Code Playgroud)

对于我在循环中添加对象,我必须以第二种方式进行.

arrays class object typescript

39
推荐指数
2
解决办法
13万
查看次数

如何在android上的TextVIew上在5秒内实现从0到600的增加数量的动画

我计划在一定秒内通过动画将textView上的整数增加从0到某个值.例如,显示动画,在textview上将数字从0增加到600,持续5秒.

我该如何实现呢?

animation android textview

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

Android ScrollView会自动滚动到视图的底部

我创建了一个活动,其中包含一个地图,图像和其他文本视图,我为它添加了"scrollview"标签...但是在活动开始后它会自动滚动到页面的末尾....请告诉我我为什么会发生这种情况以及如何阻止它形成移动结束所以我可以自己滚动.

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="vertical"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.radikallab.earch.DetailsActivity"
android:background="@drawable/background10">


<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="25dp"
        android:text="Title"
        android:textStyle="italic"/>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/background4"
        android:id="@+id/iv"/>


    <TextView
        android:id="@+id/rat"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:text="Title"
        android:textStyle="italic"/>

    <TextView
        android:id="@+id/addr"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="17sp"
        android:text="Title"
        android:textStyle="italic"/>

    <WebView

        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:layout_marginTop="10dp"
        android:id="@+id/webView"
        android:layout_gravity="center_horizontal" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android

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

具有Swift容量的数组

如何在没有RepeatedValues的情况下初始化具有最大容量的阵列?

var anotherThreeDoubles = Array(count: 3, repeatedValue: 2.5)
Run Code Online (Sandbox Code Playgroud)

就像在这个例子中使用repeatedValue一样.我们可以初始化没有价值吗?

swift

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

AsyncTask HttpPost在3G上执行失败,但适用于Wifi

我需要在Web服务上做一些字符串的Http帖子.我正在使用KSoap.

@Override
protected JSONObject doInBackground(JSONObject... params) {
    String result;

    HttpParams httpParameters = new BasicHttpParams();
    // Set the timeout in milliseconds until a connection is established.
    // The default value is zero, that means the timeout is not used. 
    int timeoutConnection = 30000;
    HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
    // Set the default socket timeout (SO_TIMEOUT) 
    // in milliseconds which is the timeout for waiting for data.
    int timeoutSocket = 50000;
    HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

    HttpClient httpclient = new DefaultHttpClient(httpParameters);
    setupClient(httpclient);
    //HttpURLConnection httpclient = new HttpURLConnection(_url);

    Log.d(TAG, …
Run Code Online (Sandbox Code Playgroud)

android ksoap2 android-asynctask

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

Google Vision API示例:让CameraSource成为焦点

我从这里结帐了最新的Google Vision API:

https://github.com/googlesamples/android-vision

我在带有KitKat的LG G2设备上运行它.我所做的唯一更改是Gradle文件中的minSdkVerion:

...
defaultConfig {
    applicationId "com.google.android.gms.samples.vision.face.multitracker"
    minSdkVersion 19
...
Run Code Online (Sandbox Code Playgroud)

但它没有集中注意力.我如何让它集中注意力?

camera android google-play-services google-vision android-vision

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

Android深层链接自定义URI

我在清单中定义了以下内容:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.package">
...
    <activity
        android:name="app.myActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="www.example.com"
                android:pathPrefix="/gizmos"
                android:scheme="http" />
            <!-- note that the leading "/" is required for pathPrefix-->
            <!-- Accepts URIs that begin with "example://gizmos”-->
            <data
                android:host="gizmos"
                android:scheme="example" />
        </intent-filter>
    </activity>
 ...
Run Code Online (Sandbox Code Playgroud)

我已经定义了我的onCreate():

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    Uri data = intent.getData();
    if (data != null) {
        Log.d("URI",data.toString());            
    }
}
Run Code Online (Sandbox Code Playgroud)

这符合Android文档:Android Deep Linking

所以问题是:

如何测试URI深层链接?根据文档我运行的东西

adb shell …

android deep-linking adb

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

亚马逊网络服务工作示例

我已经搜索了高低,试图让产品广告API工作 - 我已经尝试了很多来自这些论坛和互联网的例子,但它不起作用.有一些关于修改WSDL的讨论,但也不起作用.

这是我去过的地方:
https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
http://aws.amazon.com/code/Product-Advertising-API/3941
http ://aws.amazon.com/code/Product-Advertising-API/2609
http://flyingpies.wordpress.com/2009/08/13/signing-amazon-product-advertising-api-cwcf-part-2/*

*这是最好的教程,直到AWS改变WSDL,没有关于如何部署的例子 - 我实际上开始怀疑他们是否在发布之前测试他们的东西!

谁能请我指出一个有效的C#示例?

编辑
我也知道
https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html上 发布的信息,
这意味着我知道每次搜索都必须包含AssociateTag.

c# amazon-web-services

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