我的导航栏中有一个UiSearchbar.SearchBar风格很小.我在iOS 8上,使用SearchController(没有SearchDisplayController)和Swift.
我想将占位符和图标颜色设置为白色.这可能吗?到目前为止我发现的所有内容似乎都已过时,或者作者不确定此代码是否会被Apple批准.
我想摆脱取消按钮,但当我尝试这个:
searchController.searchBar.showsCancelButton = false
在viewDidLoad中,取消按钮仍然显示.
我必须说,我正在以编程方式创建searchBar ..
我只是不知道如何计算MKMapView上的区域.有谁解决了这个问题呢?
这是我的代码,但它返回的方式太多了:
func ringArea() -> Double{
var area: Double = 0
if templocations.count > 2 {
var p1,p2:CLLocationCoordinate2D
for var i = 0; i < templocations.count - 1; i++ {
var loc = templocations[i] as CLLocation
p1 = CLLocationCoordinate2D(latitude: loc.coordinate.latitude, longitude: loc.coordinate.longitude)
loc = templocations[i+1] as CLLocation
p2 = CLLocationCoordinate2D(latitude: loc.coordinate.latitude, longitude: loc.coordinate.longitude)
var sinfunc: Float = (2 + sinf(Float(degreeToRadiant(p1.latitude))) + sinf(Float(degreeToRadiant(p2.latitude))))
area += degreeToRadiant(p2.longitude - p1.longitude) * Double(sinfunc)
}
area = area * kEarthRadius * kEarthRadius / 2;
} …Run Code Online (Sandbox Code Playgroud) 我有以下问题:
主要活动:
<android.support.design.widget.CoordinatorLayout
.......>
<android.support.design.widget.AppBarLayout
......>
<android.support.v7.widget.Toolbar
app:layout_scrollFlags="scroll|enterAlways"
....../>
</android.support.design.widget.AppBarLayout>
<FrameLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior"
....../>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
当FrameLayout包含带有recyclerview的片段时,向上滑动recyclerview确实会向上滚动工具栏。
问题在于以下情况:
此代码执行片段更改:
fragment = .. get new fragment ..
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frame, fragment);
fragmentTransaction.commit();
Run Code Online (Sandbox Code Playgroud)
添加此代码无济于事:
getSupportActionBar().show();
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
toolbar.translationY(0).start();
Run Code Online (Sandbox Code Playgroud)
但没有成功。
如何以编程方式使向上滚动(不可见)工具栏再次向下滚动?
android material-design android-5.0-lollipop android-toolbar
我正在使用下面PercentFrameLayout的项目RecyclerView是我的布局.PercentFrameLayout没有出现.它没有出现.
我在这里缺少什么......?
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/header_image_view"
android:layout_width="match_parent"
app:layout_heightPercent="12%"
android:background="@drawable/placeholder_image"/>
</android.support.percent.PercentFrameLayout>
Run Code Online (Sandbox Code Playgroud) 我正在构建一个Cardboard应用程序并在Nexus 6P上进行测试.我遇到的问题是,当我安装应用程序时,它不会要求任何权限.在我的清单中我有这个:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Run Code Online (Sandbox Code Playgroud)
然后,如果我想在我的应用程序中从互联网上下载一些文件,它不起作用.它甚至没有创建com.夹.
我必须手动转到应用信息并检查存储权限.
这很奇怪,因为在为GearVR构建应用程序并在Note 4上进行测试时,它会要求许可(在Note 4中我使用sd卡,在Nexus 6P内部)
为什么会这样?
谢谢.
android unity-game-engine android-permissions android-6.0-marshmallow
如何检测用户在我的应用程序中启动了哪个应用程序,即即使我的应用程序未在前台或后台运行,当用户启动 Whatsapp 时,我的应用程序也应收到通知。
远足信使已经实现了与无障碍服务相同的功能。
我怎么解决这个问题 ?
提前致谢!!
在android 6中,我正在请求使用存储的权限.现在,当用户拒绝我的请求时,我想向他显示一个对话框,解释为什么需要该应用程序的权限才能获得他的许可.
如何才能做到这一点?
是否有任何内置对话框,如使用请求权限方法时弹出的对话框?
android android-permissions android-6.0-marshmallow runtime-permissions
我试图将Google signin SDK包含到我的AppDelegate.m文件中,它会抛出此错误.

它就像我只能定义方法的一个实例.
// Facebook SDK
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [RNGoogleSignin application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
@end
Run Code Online (Sandbox Code Playgroud) 我正在努力将一些视频集成到我的一项活动中。它播放得很好,但我必须单击“播放”才能真正播放。我搜索了论坛和开发者网站,但找不到任何与自动播放或自动启动相关的内容。有什么建议么?
MainActivity.java
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
VideoView mVideoView = (VideoView) findViewById(R.id.videoView);
mVideoView.setVideoPath("file:///android_asset/video1.MP4");
mVideoView.setMediaController(new MediaController(this));
mVideoView.seekTo(1);
//mVideoView.requestFocus();
}
Run Code Online (Sandbox Code Playgroud)
我的 contains_main.xml
<fragment 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/fragment"
android:name="imaker.MediaAutoPlay.MainActivityFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layout="@layout/fragment_main">
<VideoView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/videoView"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
</fragment>
Run Code Online (Sandbox Code Playgroud) 我正在用Swift编写一个iOS应用程序,该应用程序可以录制用户的语音,然后可以播放一些语音效果,但是问题是,使用内置的iPhone麦克风时,播放非常安静。使用耳机没有问题。
记录代码:
let recordingName = "my_audio.m4a"
let pathArray = [dirPath, recordingName]
let filePath = NSURL.fileURLWithPathComponents(pathArray)
print(filePath)
let recordSettings: [String: AnyObject] = [
AVFormatIDKey: Int(kAudioFormatAppleLossless),
AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue,
AVEncoderBitRateKey : 320000,
AVNumberOfChannelsKey: 2,
AVSampleRateKey : 44100.0
]
let session = AVAudioSession.sharedInstance()
try! session.setCategory(AVAudioSessionCategoryPlayAndRecord)
try! audioRecorder = AVAudioRecorder(URL: filePath!, settings: recordSettings)
audioRecorder.meteringEnabled = true
audioRecorder.updateMeters()
audioRecorder.delegate = self
audioRecorder.prepareToRecord()
audioRecorder.record()
Run Code Online (Sandbox Code Playgroud)
播放代码:
playerNode.stop()
playerNode.volume = 1.0
audioEngine.stop()
audioEngine.reset()
audioEngine.attachNode(playerNode)
audioEngine.attachNode(audioUnitTime)
audioEngine.connect(playerNode, to: audioUnitTime, format: receivedAudio.processingFormat)
audioEngine.connect(audioUnitTime, to: audioEngine.outputNode, format: receivedAudio.processingFormat)
playerNode.scheduleFile(receivedAudio, atTime: nil, …Run Code Online (Sandbox Code Playgroud) android ×6
swift ×3
autoplay ×1
avfoundation ×1
ios ×1
iphone ×1
mapkit ×1
mkmapview ×1
objective-c ×1
uisearchbar ×1