小编cod*_*man的帖子

在Android模拟器中切换到横向模式

这可能是一个很容易回答的问题,但经过几个小时的搜索文档和Google后,我自己找不到解决方案.我将Android应用的方向设置landscapeAndroidManifest.xml文件中:

android:screenOrientation="landscape"
Run Code Online (Sandbox Code Playgroud)

但是,当我在模拟器中运行应用程序时,它会出现在横向和纵向模式下.如何将模拟器切换到landscape模式mac?它正在运行1.6 SDK.

android android-emulator

352
推荐指数
6
解决办法
18万
查看次数

比较Swift中的两个版本字符串

我有两个不同的应用程序版本字符串(即"3.0.1"和"3.0.2").

如何使用Swift比较这些?

ios swift

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

iOS 8 - 在Interface Builder中更改UILabel上的字符间距

无论如何使用Interface Builder更改UILabel文本上的字符间距(轨道)?如果没有,有没有办法在已经使用属性文本创建的现有UILabel上以编程方式执行此操作?

interface-builder uilabel ios swift

45
推荐指数
8
解决办法
5万
查看次数

在Android中按下按钮时触发事件

我有以下Android代码,一旦按下按钮就可以播放声音:

Button SoundButton2 = (Button)findViewById(R.id.sound2);
        SoundButton2.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(2);

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

我的问题是我希望在按下按钮(触摸下来)时立即播放声音,而不是在释放声音时(触摸起来).有关如何实现这一目标的任何想法?

android button

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

使用Realm按多个属性排序

如何使用多个属性订购我的Realm结果?

我首先使用这样的属性对它们进行排序:

allShows = Show.allObjects().sortedResultsUsingProperty("dateStart", ascending: true)
Run Code Online (Sandbox Code Playgroud)

但现在我也想通过另一个属性"timeStart"进行二次排序.我试过这样的:

allShows = Show.allObjects().sortedResultsUsingProperty("dateStart", ascending: true).sortedResultsUsingProperty("timeStart", ascending: true)
Run Code Online (Sandbox Code Playgroud)

这只会使结果仅由第二个属性排序.请帮忙.

realm ios swift

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

Android自动Google Play拒绝

由于以下原因,Google一直拒绝我的应用:"在审核期间,我们发现如果在插入Android Auto体验时设备上播放音频,则音乐将继续通过汽车扬声器播放而无需用户意图.我们将此视为司机分心,并不适合Android Auto应用程序."

我认为我已经采取了相应的步骤来解决这个问题,请按照此处的文档进行操作:https://developer.android.com/training/auto/audio/index.html#isconnected

然而,出于同样的原因,他们再次拒绝了我.

在我的MediaBrowserServiceCompat StreamService类中,我添加了以下代码:

private IntentFilter androidAutoConnectionIntentFilter = new IntentFilter("com.google.android.gms.car.media.STATUS");
private AndroidAutoConnectionStatusReceiver androidAutoConnectionStatusReceiver = new AndroidAutoConnectionStatusReceiver();
Run Code Online (Sandbox Code Playgroud)

在onCreate()中,我添加了:

registerReceiver(androidAutoConnectionStatusReceiver, androidAutoConnectionIntentFilter);
Run Code Online (Sandbox Code Playgroud)

并将此类添加到服务中:

private class AndroidAutoConnectionStatusReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            System.out.println("*** ANDROID AUTO CONNECTED: " + intent);
            String status = intent.getStringExtra("media_connection_status");
            boolean isConnectedToCar = "media_connected".equals(status);
            if (isConnectedToCar) {
                // android auto connected so stop playback
                Intent stopIntent = new Intent(context, StreamService.class);
                stopIntent.setAction(StreamService.ACTION_PLAYER_STOP);
                context.startService(stopIntent);
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

知道我如何更新我的应用程序以解决这种拒绝?

android android-auto

15
推荐指数
0
解决办法
671
查看次数

有条件地构建具有不同资产目录的应用程序

我的XCode项目以多种配置的方式设置,允许我为我的应用程序的不同变体使用相同的代码库,但每个都有独特的元素,如应用程序名称,版本,包标识符,图标,启动屏幕等我已经关注了这个网站,以便进行大部分设置:http: //appfoundry.be/blog/2014/07/04/Xcode-Env-Configuration/

我还有一个config.plist,其中包含与每个XCode配置相关联的各种唯一设置,这些设置只能在构建时成功复制.以下是运行脚本构建阶段的片段,以便执行此操作:

RESOURCE_PATH=${SRCROOT}/${PRODUCT_NAME}/config/${CONFIGURATION}

BUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app

echo "Copying all files under ${RESOURCE_PATH} to ${BUILD_APP_DIR}"
cp -v "${RESOURCE_PATH}/"* "${BUILD_APP_DIR}/"
Run Code Online (Sandbox Code Playgroud)

我的下一个目标是能够在构建时复制特定配置的资产目录,以避免将所有不同配置的图像捆绑到构建中,从而导致它变得臃肿.我使用Run Script尝试了与上面相同的解决方案,更改了复制行以包含递归选项(因为资产目录本质上是一个目录):

cp -rv "${RESOURCE_PATH}/"* "${BUILD_APP_DIR}/"
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,我的应用程序无法构建,并说它无法找到应用程序图标并启动图像.有任何想法吗?

xcode xcodebuild ios

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

NSPredicate数组内对象内的过滤器数组

我有以下方法:

- (NSMutableArray *)getFilteredArrayFromArray:(NSMutableArray *)array withText:(NSString *)text {

if ([array count] <= 0)
    return nil;

NSMutableArray *arrayToFilter = [NSMutableArray arrayWithArray:array];
NSString *nameformatString = [NSString stringWithFormat:@"stationName contains[c] '%@'", text];
NSPredicate *namePredicate = [NSPredicate predicateWithFormat:nameformatString];

NSString *descformatString = [NSString stringWithFormat:@"stationTagline contains[c] '%@'", text];
NSPredicate *descPredicate = [NSPredicate predicateWithFormat:descformatString];

NSString *aToZformatString = [NSString stringWithFormat:@"stationSearchData.browseAtozArray.city contains[c] '%@'", text];
NSPredicate *aToZPredicate = [NSPredicate predicateWithFormat:aToZformatString];

NSPredicate * combinePredicate = [NSCompoundPredicate orPredicateWithSubpredicates:[NSArray arrayWithObjects:namePredicate, descPredicate, aToZPredicate, nil]];

[arrayToFilter filterUsingPredicate:combinePredicate];

return arrayToFilter;
}
Run Code Online (Sandbox Code Playgroud)

前2个谓词工作正常.但最后一个(aToZPredicate),是行不通的.stationSearchData是一个StationSearchData对象,而browseAtozArray是一个NSMutableArray.

如何使用谓词基本上搜索数组中数组中的数组?

这是StationSearchData对象的接口:

@interface StationSearchData : …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

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

使用OnTouchListener时,如何更改Android中ImageButton上的图像?

我有以下代码创建一个ImageButton并在单击时播放声音:

ImageButton SoundButton1 = (ImageButton)findViewById(R.id.sound1);
SoundButton1.setImageResource(R.drawable.my_button);

SoundButton1.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN ) {
            mSoundManager.playSound(1);
            return true;
        }

        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

问题是我希望按下它时ImageButton上的图像会发生变化.OnTouchListener似乎覆盖了触摸并且不允许图像更改.一旦我删除了OnTouchListener,ImageButton会在按下时切换到不同的图像.关于如何在仍然使用OnTouchListener时在ImageButton上更改图像的任何想法?非常感谢你!

android imagebutton

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

领域:按子对象中的属性排序

我的Show对象如下所示:

class Show: RLMObject {
    dynamic var venue: Venue?
}
Run Code Online (Sandbox Code Playgroud)

和我的Venue对象:

class Venue: RLMObject {
    dynamic var title = ""
}
Run Code Online (Sandbox Code Playgroud)

我需要能够通过Venue对象的标题对Show对象进行排序.我尝试了以下但出现了错误:

allShowsByLocation = Show.allObjects().sortedResultsUsingProperty("venue.title", ascending: true)
Run Code Online (Sandbox Code Playgroud)

错误是:无效的排序列',原因:'找不到列'(null)'.

realm ios swift

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