小编Cha*_*gUZ的帖子

什么是Xcode项目中的"UserInterfaceState.xcuserstate"文件?

我用的是svnX.

导入项目时,我检查"不忽略"选项.(用于导入libOAuth.a,...)

但是一个文件引起了一个小问题.

UserInterfaceState.xcuserstate

这是什么文件?

我可以忽略这个文件吗?那很重要么?我应该提交这个文件吗?

svn version-control xcode commit

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

什么是__NSArrayI和__NSArrayM?如何转换为NSArray?

什么是__NSArrayI和__NSArrayM?

__NSArrayI(或M)导致"无法识别的选择器"错误.

如何转换为NSArray?


我做了测试解析json,twitter api.

http://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=twitterapi

==>工作正常.解析对象是NSCFDictionary类.(这个字典包含__NSArrayM类)

http://api.twitter.com/1/statuses/user_timeline.json?&screen_name=twitterapi

==>错误.解析对象是__NSArrayM类.

iphone objective-c nsarray nsobject ios

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

使用actionbar home作为向上按钮,home活​​动saveInstanceState始终为null

活动A ===单击按钮===>活动B.

按下后退按钮时,不会重新创建活动A.

按home键作为向上按钮时,将重新创建活动A.

所以我在A.onSaveInstanceState(Bundle outState)时保存状态,并在A.onRestoreInstanceState(Bundle savedInstanceState)时使用状态.

保存和使用工作正常(除了主页作为向上按钮)

.

然而,

当按下home作为向上按钮时,系统重新创建活动A,并且savedInstanceState消失.

我如何使用已保存的实例状态?

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
        // I do not want this... 
        // Home as up button is to navigate to Home-Activity not previous acitivity
            super.onBackPressed();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
Run Code Online (Sandbox Code Playgroud)

android android-actionbar

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

如何在Java中解析或拆分URL地址?

如果我有网址.

https://graph.facebook.com/me/home?limit=25&since=1374196005

我可以得到(或拆分)参数(避免硬编码)吗?

像这样

https /// graph.facebook.com /// me/home /// {limit = 25,sincse = 1374196005}

java android facebook-graph-api

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

如何知道应用是否被用户或iOS终止(10分钟背景后)

如何知道在重新启动应用时,用户或iOS是否终止了应用>

"按用户"表示"通过双击主页按钮并按 - 按钮".被用户杀死

'通过iOS'意味着"应用程序成为后台运行状态,iOS终止应用程序10分钟后"

iphone background termination ios

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

如何获取Documents目录中文件的所有路径?

我通常使用路径NSBundle.

但是,NSBundle不包含Documents文件夹.

如何获取Documents目录中文件的所有路径(或名称)?

iphone xcode nsfilemanager nsbundle ios

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

使用path,pathPrefix或pathPattern的Intent过滤器

我的测试uri字符串是

http://test.host.com/path/test.html?key1=val1&key2=val2

我在清单中制作了意图过滤器

A.计划和主持人(它有效,但我不想)

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <data
        android:scheme="http"
        android:host="test.host.com"
    />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

B. A&path(pathPrefix,pathPattern)(不起作用)

    <data
        android:scheme="http"
        android:host="test.host.com"

        1. android:path="path/test.html" -> not worked (link to chrome broswer)
        2. android:path="path"           -> not worked (link to chrome broswer)
        3. android:pathPrefix="path"     -> not worked (link to chrome broswer)
        4. android:pathPattern="user/invite.*"  -> same (I do not know pattern)

    />
Run Code Online (Sandbox Code Playgroud)

我想开始我的应用程序时(路径/ test.html中)

android uri intentfilter android-intent

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

检查GPS是否打开在Kitkat(4.4)

在kitkat下面,如果gps在供应商列表中,我会得到

String providers = Secure.getString(context.getContentResolver(), Secure.LOCATION_PROVIDERS_ALLOWED);
if (TextUtils.isEmpty(providers)) {
    return false;
}
return providers.contains(LocationManager.GPS_PROVIDER);
Run Code Online (Sandbox Code Playgroud)

但在kitkat中,不推荐使用Secure.LOCATION_PROVIDERS_ALLOWED.

Javaodc说"使用Secure.LOCATION_MODE",位置模式如下......

Secure.LOCATION_MODE_OFF
Secure.LOCATION_MODE_SENSORS_ONLY
Secure.LOCATION_MODE_BATTERY_SAVING
Secure.LOCATION_MODE_HIGH_ACCURACY
Run Code Online (Sandbox Code Playgroud)

但我不知道下面的代码是否正确.(我没有kitkat设备)

int locationMode = Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE);
boolean isGpsOn = locationMode != Secure.LOCATION_MODE_OFF;
Run Code Online (Sandbox Code Playgroud)

如果不正确,请回答正确的代码.

编辑

我知道LocationManager.但它需要ACCESS_FINE_LOCATION权限.我不需要"访问"位置.

LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );
boolean isGpsOn = manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) 
Run Code Online (Sandbox Code Playgroud)

android android-4.4-kitkat

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

10
推荐指数
2
解决办法
5148
查看次数

我想在对话框片段中设置最大高度

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:minWidth="@dimen/dialog_min_width"
    android:padding="@dimen/dialog_padding"
    android:background="@drawable/dialog_background" >

    <TextView android:id="@+id/base_dialog_title"
        style="@style/DialogTitleTextViewStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:gravity="center" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="16dp" >
    </FrameLayout>

<!-- *********************** HERE ************************* -->

    <FrameLayout android:id="@+id/base_dialog_content"
        android:background="@drawable/dialog_description_background"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </FrameLayout>

<!-- *********************** HERE ************************* -->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="16dp" >
    </FrameLayout>

    <LinearLayout android:id="@+id/base_dialog_button_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="horizontal">

    <Button
        android:id="@+id/base_dialog_button_negative"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:visibility="gone"/>

    <Button
        android:id="@+id/base_dialog_button_neutral"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:visibility="gone"/>

    <Button
        android:id="@+id/base_dialog_button_positive"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:visibility="gone"/>

    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是对话框片段布局.

我将内容视图(TextView或ListView)添加到FrameLayout(@ id/base_dialog_content)

当ListView有很多项时,Dialog在窗口中是全高.

我想设置最大高度对话框或内容视图(或列表视图) …

android android-layout android-linearlayout

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