我使用Alamofire上传多部分表单数据中的图像.我成功实现了目标.每次上传图片时,我都会调用"uploadDocWebService"函数.因此,调用函数的次数等于图像的数量.我无法确定每次通话的结果.我的图片上传成功.如果服务器出现故障或互联网连接失败导致上传失败,我无法确定哪个图像应该从视图中删除,哪个失败了.我将indexPath作为每个图像上传的参数传递.但是,在收到第一次上传图像的结果之前,indexPath会更新到最新的图像上传.任何人都可以建议我更好地应对这种情况.
这是我用于图片上传的代码:
func uploadDocWebservice(fileUrl: NSURL , progressView : PWProgressView , index : String , imageData : NSData? , name : String , mimeType : String , uploadType : String){
let url = "\(kBaseURL)\(uploadDocsUrl)"
var type = String()
var networkGroupId = String(SingletonClass.sharedInstance.selectedNetworkId!)
if SingletonClass.sharedInstance.groupPopUp == true {
type = "group"
networkGroupId = String(SingletonClass.sharedInstance.selectedSubNetworkOrGroup!)
}else {
type = "network"
}
Alamofire.upload(
.POST,
url,
multipartFormData: { multipartFormData in
if uploadType == "Image" {
multipartFormData.appendBodyPart( data: imageData! , name: "file", fileName: name, mimeType: mimeType) …Run Code Online (Sandbox Code Playgroud) 我试图开发一个与此应用类似的iOS 应用。
我需要计算两个城市或两个位置之间的中间位置。我不知道哪个API是最好的。我尝试了Google Directions API。但这并不提供两个位置之间的位置。谁能建议一个API。我需要尽快实施。
谢谢
我需要底页在两个位置停下来。我的底表有以下代码。
<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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
....
</RelativeLayout>
<FrameLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:minHeight="1000dp"
android:orientation="vertical">
....
</LinearLayout>
</ScrollView>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
和
View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);
final BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
// React to state change
Log.e("onStateChanged", "onStateChanged:" + newState);
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
behavior.setPeekHeight(600);
showAgain.setVisibility(View.GONE);
mMap.getUiSettings().setScrollGesturesEnabled(false);
} else if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
if (behavior.getPeekHeight() …Run Code Online (Sandbox Code Playgroud) 我添加了一个最初不可编辑的 uitextview。我添加了一个点击手势,使编辑成为真。在点击手势选择器中,我得到正在点击的单词。我尝试了很多解决方案,但没有一个作为完整的解决方案对我有用。如果不滚动 textview,则每个解决方案都有效。但是,如果我滚动 textview,则不会检索到确切的单词。这是我获取点击词的代码:
@objc func handleTap(_ sender: UITapGestureRecognizer) {
notesTextView.isEditable = true
notesTextView.textColor = UIColor.white
if let textView = sender.view as? UITextView {
var pointOfTap = sender.location(in: textView)
print("x:\(pointOfTap.x) , y:\(pointOfTap.y)")
let contentOffsetY = textView.contentOffset.y
pointOfTap.y += contentOffsetY
print("x:\(pointOfTap.x) , y:\(pointOfTap.y)")
word(atPosition: pointOfTap)
}
func word(atPosition: CGPoint) -> String? {
if let tapPosition = notesTextView.closestPosition(to: atPosition) {
if let textRange = notesTextView.tokenizer.rangeEnclosingPosition(tapPosition , with: .word, inDirection: 1) {
let tappedWord = notesTextView.text(in: textRange)
print("Word: \(tappedWord)" ?? "")
return tappedWord …Run Code Online (Sandbox Code Playgroud) 我尝试了谷歌地图提供的所有动画方法。但是我无法为地图视图的缩放级别设置动画。我试过 mapView.animateToZoom(15)。还
UIView.animateWithDuration(5.0, animations: {
let zoomIn = GMSCameraUpdate.zoomTo(15)
self.mapView.animateToZoom(15)
})
Run Code Online (Sandbox Code Playgroud)
但我无法实现动画。我也跟着GMSMapView animateToCameraPosition zoom in - zoom out animation
但没有希望。有人可以帮忙吗?
ios ×4
swift ×3
google-maps ×2
alamofire ×1
android ×1
bottom-sheet ×1
google-api ×1
iphone ×1
java ×1
objective-c ×1
uitextview ×1
xcode ×1