答案 0 :(得分:1)
输入项目路径,如:
package com.example.android.m_tour;
import android.content.Intent;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.wnafee.vector.MorphButton;
import java.util.HashMap;
import java.util.Locale;
import static com.example.android.m_tour.R.id.mb;
public class guide extends AppCompatActivity implements MorphButton.OnStateChangedListener {
private Button settingsButton;
private String data, s;
private TextView textView;
private static TextToSpeech textToSpeech;
//qr code scanner object
private MainActivity mainActivity;
private TTSsettings ttSsettings;
private MorphButton control;
private Locale loc;
private String pr[];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guide);
control = (MorphButton) findViewById(mb);
mainActivity = new MainActivity();
textView = (TextView) findViewById(R.id.textview);
textView.setText(mainActivity.getData());
settingsButton = (Button) findViewById(R.id.settings);
ttSsettings = new TTSsettings();
loc = new Locale("en_IN");
control.setOnStateChangedListener(this);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(guide.this, TTSsettings.class);
startActivity(intent);
/*textToSpeech.stop();
Intent intent = new Intent();
intent.setAction("com.android.settings");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);*/
}
});
data = mainActivity.getData();
onStart();
textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int i) {
if (i == TextToSpeech.SUCCESS) {
//set language Locale to US
int result = textToSpeech.setLanguage(loc);
//check that is language locale available on device or supported
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(guide.this, "Leanguage not present", Toast.LENGTH_SHORT).show();
} else {
speakOut();
}
} else {
//show toast if initialization failed
Toast.makeText(getBaseContext(), "TTS Engine Initilization Failed!", Toast.LENGTH_SHORT).show();
}
textToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListener() {
@Override
public void onStart(String s) {
//if ("id".equals(s)
Toast.makeText(guide.this, "onStart works", Toast.LENGTH_SHORT).show();
}
@Override
public void onDone(String s) {
//if ("id".equals(s))
Toast.makeText(guide.this, "onDone works", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(String s) {
//if ("id".equals(s))
Toast.makeText(guide.this, "OnError works", Toast.LENGTH_SHORT).show();
}
});
}
});
}
@Override
public void onDestroy() {
// Don't forget to stop and shutdown text to speech engine!
if (textToSpeech != null) {
textToSpeech.stop();
textToSpeech.shutdown();
}
super.onDestroy();
}
@Override
public void onStateChanged(MorphButton.MorphState changedTo, boolean isAnimating) {
if (changedTo == MorphButton.MorphState.END) {
textToSpeech.stop();
} else {
speakOut();
}
}
private void speakOut() {
HashMap<String, String> params = new HashMap<String, String>();
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "id");
textToSpeech.setPitch((float) ttSsettings.getPitchRate());
textToSpeech.setSpeechRate((float) ttSsettings.getSpeechRate());
textToSpeech.speak(pr[1], TextToSpeech.QUEUE_FLUSH, params);
}
//getters
public String getData() {
return data;
}
public static TextToSpeech getTextToSpeech() {
return textToSpeech;
}
}
现在打开新窗口,其中包含文件列表,您可以看到Library/Developer/Xcode/DerivedData/yourprojectname/Build/Products/Debug-iphoneos
文件。
现在,
打开终端并输入yourApp.app
然后只需将cd
(从查找程序窗口)拖到终端,现在您将获得应用程序的路径,现在按回车键。
现在输入以下命令:
xattr -rc。
最后不要忘记“。”(点)。
按enter按钮。
现在,转到Xcode项目并清理并重新运行。
修改强>
它是关于您之前使用的路径未命中匹配和缓存路径的全部内容。因此,在执行上述步骤时,您将清除项目的构建路径,这将使xcode项目在不进行缓存的情况下以新的方式运行。
制作项目的副本并使用xcode运行相同的项目会产生问题或将项目保留在icloud中并从该位置运行也会产生问题。
愿这有帮助。
答案 1 :(得分:0)
我刚刚更改了codeSign - &gt;发布到iOS发行版然后我把它放回iOS开发人员然后我做了一个简单的干净。 这解决了我的问题(发现它很奇怪!!!)。