小编Ale*_*cus的帖子

@try - 在Objective-c中捕获块

为什么@try阻止工作?它崩溃了应用程序,但它应该被@try块捕获.

 NSString* test = [NSString stringWithString:@"ss"];

 @try {
    [test characterAtIndex:6];

 }
 @catch (NSException * e) {
    NSLog(@"Exception: %@", e);
 }
 @finally {
    NSLog(@"finally");
 }
Run Code Online (Sandbox Code Playgroud)

iphone objective-c try-catch-finally nsexception

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

Google API控制台 - 缺少客户端密码

我尝试为Android应用程序创建测试客户端ID,该应用程序使用OAUTH 2.0作为登录来检索用户配置文件.我按照步骤在谷歌控制台上完成客户端ID的创建,但我没有看到客户端秘密的任何地方.我正在尝试帮助我的雇主获取谷歌凭据的应用程序.我知道如何在android中实现OAUTH 2.0,但我需要客户端密钥来使用访问令牌交换代码.

首先,我从"服务"标签中选择了"Google+ API".然后按照API Access选项卡中的屏幕步骤操作.在此输入图像描述

oauth-2.0

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

在后台运行iOS HTTP请求

当应用程序处于后台时,可以向PHP服务器发出HTTP异步请求吗?该应用程序是基于位置的应用程序,应该收集当前位置并每隔5(或其他值)分钟将坐标发送到服务器.即使应用程序在后台,我可以将http帖子发送到服务器吗?我读了很多关于这方面的想法,但有些人告诉我们可以做到,有些则无法完成.

谢谢,

亚历克斯.

iphone objective-c core-location

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

Apple拒绝,因为UIBackgroundMode = location

我提交了一个应用程序,它以用户选择的固定间隔(5分钟,10分钟,30分钟,1小时)跟踪用户的位置(并将其发送到服务器).该应用程序也应该在后台工作(发送请求),我已将其声明为UIBackgroundMode = location.我可以在后台以固定的间隔发送请求.Apple拒绝了它,建议如下:

我们发现您的应用使用后台模式,但不包含要求该模式持续运行的功能.此行为不符合App Store审查指南.

我们注意到您的应用程序在Info.plist中的UIBackgroundModes键中声明了对位置的支持,但不包括需要持久位置的功能.

在应用程序处于后台时添加需要持续使用实时位置更新的功能或从UIBackgroundModes键中删除"位置"设置是合适的.如果您的应用程序不需要持久的实时位置更新,我们建议您使用重要更改位置服务或区域监控位置服务.

有关这些选项的更多信息,请参阅位置感知编程指南中的"启动重要更改位置服务"和"监控基于形状的区域"部分.

如果您选择添加使用位置背景模式的功能,请在您的应用程序说明中包含以下电池使用免责声明:

"继续使用GPS在后台运行会大大降低电池寿命."

如果我更改了重要的位置更改并UIBackgroundMode从中删除了密钥Info.plist,则应用程序将在后台被杀死,并且只有在事件发生时才会唤醒.但是我必须每隔5分钟将请求发送到服务器,并且我的应用程序在后台被杀死(假设用户没有移动,事件不是trigger = no请求被发送到服务器).

appstore-approval cllocationmanager ios

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

如何在窗口中居中弹出窗口(Windows应用商店应用)

我有一个自定义弹出窗口(作为用户控件),我以编程方式加载.我无法将其居中于x轴,仅在垂直方向上.弹出窗口未添加到xaml文件中,但会在根窗口中添加.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Windows;
using Windows.UI.Core;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace QSTLibrary.WIN8.Tools
{
    public sealed partial class CustomProgressRingPopup : UserControl
    {

        public CustomProgressRingPopup()
        {
            this.InitializeComponent();
        }

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        // Using a DependencyProperty as the backing store …
Run Code Online (Sandbox Code Playgroud)

c# xaml windows-store-apps

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

关闭两个模态视图控制器

我有一个导航控制器,它提供一个模态viewController.从这个模态viewController里面我提出了另一个模态viewController.我想要的是从最后一个模态viewController返回到navigationController(根viewController).类似于popToRootViewController,但适用于modalViewControllers;

NavigationController - > present Modal ViewController A - >现在的Modal ViewController B.

从模态ViewCOntroller BI想要返回navigationCOntroller.

这可能吗?

欣赏,亚历克斯.

objective-c modalviewcontroller

9
推荐指数
2
解决办法
7334
查看次数

AudioRecord:缓冲区溢出?

RECORDING使用我的应用程序时,我正在获得缓冲区溢出.录音在a中执行Service.我无法弄清楚为什么我收到这条消息AudioFlinger.

下面我实例化AudioRecord对象并设置它的回调.

bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
aRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, bufferSize);

aRecorder.setRecordPositionUpdateListener(updateListener);

bytesPerSample = bitsPerSample / 8;
int bytesPerFrame = nChannels * bytesPerSample;
framePeriod = bufferSize / bytesPerFrame; // nr of frames that can be kept in a bufferSize dimension    
int result = aRecorder.setPositionNotificationPeriod(framePeriod);    
buffer = new byte[bufferSize];
Run Code Online (Sandbox Code Playgroud)

audioRecord回调:

private AudioRecord.OnRecordPositionUpdateListener updateListener = new AudioRecord.OnRecordPositionUpdateListener(){
        public void onPeriodicNotification(AudioRecord recorder){
            int result = aRecorder.read(buffer, 0, buffer.length);
        }

        public void onMarkerReached(AudioRecord …
Run Code Online (Sandbox Code Playgroud)

android buffer-overflow audiorecord android-audiorecord

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

一个XCode Project多个iPhone应用程序

我尝试使用相同的XCode项目创建多个iPhone应用程序并且工作正常,但是当我想将所有这些应用程序安装到我的iPhone,iTunes而不是将第二个应用程序添加为新应用程序时,它想要替换现有的应用程序(第一个)安装)与第二个.我为每个应用程序使用了不同的目标,并制作了一个脚本,将相应的图像复制到Default.png.我的应用程序将有不同的发行版,所以我需要弄清楚如何部署应用程序以便iTunes安装这些作为单个应用程序,而不是将我的所有应用程序视为单个应用程序.

你能帮帮我吗?

欣赏,亚历克斯.

iphone deployment xcode

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

工具栏重叠在状态栏下方

当用户滚动回收器视图时,我使用CoordinatorLayout和AppBarLayout来隐藏/显示工具栏.问题是工具栏仍然在状态栏下可见.看图像("Test2"标题仍然可见):

在此输入图像描述

我添加了fitSystemWindows标志,当然:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="software.cia.test2.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android material-design

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

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
查看次数