Tag: swift3

当用Swift 3触摸时,在Webview中获取pdf的实际坐标

我已经成功地从URL加载PDF文件到Web视图。 我想获取触摸后的webview的坐标发送到服务器的数据添加一些文本到服务器端的位置。 问题是我怎样才能得到这个坐标当webview缩放或滚动到页2,3 ..你能帮我解决在Swift 3中的问题 这里的代码 class ViewController: UIViewController, UITextFieldDelegate, UIGestureRecognizerDelegate, UIWebViewDelegate { @IBOutlet var imageView: UIImageView! @IBOutlet var webView: UIWebView! override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "http://www.pdf995.com/samples/pdf.pdf")! webView.loadRequest(URLRequest(url: url)) let webViewTapped = UITapGestureRecognizer(target: self, action: #selector(self.tapAction(_:))) webViewTapped.numberOfTouchesRequired = 1 webViewTapped.delegate = self webView.addGestureRecognizer(webViewTapped) } func tapAction(_ sender: UITapGestureRecognizer) { // This […]

iOS ADMOB基于奖励的video广告加载失败

直到今天我能够显示奖励video,但现在的video不出现,admod的日志提醒我安装新的 ADMOB SDK 7.23.0 现在使用新的ADMOB SDK奖励video无法加载。 与testingID ,似乎工作: GADRewardBasedVideoAd.sharedInstance().load(GADRequest(),withAdUnitID: "ca-app-pub-3940256099942544/1712485313") 如果我更改了我的参考ID,video将无法加载。 我也join了AppDelegate: //ADMOB import GoogleMobileAds func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { //ADMOB GADMobileAds.configure(withApplicationID: AppConfiguration.AdMob.ID_APP) return true }

尝试呈现其视图不在窗口层次结构中的vc

我试图在线程中打开文件,这里是我的代码: DispatchQueue.main.async(execute: { () -> Void in var documentsURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).appendPathComponent(“File.pdf") self.docController = UIDocumentInteractionController.init(url: documentsURL as URL) self.docController?.delegate = self as? UIDocumentInteractionControllerDelegate self.docController?.presentPreview(animated: true) self.docController?.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true) }) 当移动到主屏幕时,此警告显示,文件未打开 Warning: Attempt to present <_UIDocumentActivityViewController: 0x…> on <HCM.PrintVacationDecisionVC: 0x…> whose view is not in the window hierarchy! 任何帮助解决这个问题?

如果单元格被触摸 – 移动另一个VC

如果细胞被触摸 – 在另一个VC上移动,我该怎么做? 我试图做,但我没有工作。 这是我的代码 override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "transData" { let destination = segue.destination as! WinnerViewController let cell = sender as? UITableViewCell if cell == cell { let indexPath = tableView.indexPath(for: cell!) if indexPath == indexPath { let productName = users[(indexPath?.row)!] destination.winner = productName.name } } } […]

'AppDelegate'不符合协议'GIDSignInDelegate'

我试图在swift-3中实现Google Signin,但是我有一个非常奇怪的错误,我正在关注链接https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift 。 但是我每次都会看到这个错误。 我在桥头添加了以下内容。 #import <Google/SignIn.h> 我已安装pod GoogleSignin pod'Google pod 'Google/SignIn' 这是我的AppDelegate文件代码 class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { //<–Here it gives the error //Method implemented but giving the error func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { //TODO } } 'AppDelegate'不符合协议'GIDSignInDelegate' 我试过重新安装豆荚 我已经尝试清洗和其他的东西,但没有注意到帮助。

不能使用UnsafeMutableRawPointertypes的参数列表调用types为UnsafePointer <_>的初始值设定项。

当我从audio缓冲区数据以multipeer连接的方式写入输出stream时,出现错误 无法使用types参数列表(UnsafeMutableRawPointer)调用UnsafePointer <_>types的初始值设定项 我find了很多解决scheme,但这个解决scheme对我没有帮助。 我的代码是: func send(_ buffer: AudioBuffer) { print(buffer.mData!) print(buffer.mDataByteSize) outputStreme?.write(UnsafePointer(buffer.mData), maxLength: buffer.mDataByteSize) } 提前致谢..:)

如何将两个UITextViews添加到UIView?

我想添加两个UITextViews到放置在UIStackView中的UIStackView 。 它工作,如果我设置UITextViews宽度和高度。 问题是我不知道如何将它们放在UIView没有设置宽度和高度。 结果应该是这样的: class PanelCell: UICollectionViewCell { let currentRunView: UIView = { let view = UIView() view.layer.cornerRadius = 5.0; view.layer.masksToBounds = true; view.backgroundColor = UIColor(hex: 0x1A1A1A) return view }() let totalRunView: UIView = { let view = UIView() view.layer.cornerRadius = 5.0; view.layer.masksToBounds = true; view.backgroundColor = UIColor(hex: 0x1A1A1A) return view }() let totalRunText: […]

我怎样才能适应X轴标签根据其栏?

我正在使用ios-chart库,并且我有一个CombinedBarChart ,默认情况下我在其中进行缩放 combinedBarChart.setScaleMinima(2, scaleY: 1) combinedBarChart.setScaleEnabled(false) 我希望每个x轴标签都会保留在每个栏的上方,但是我无法使其正常工作。 这是我的例子: 正如你所看到的,x轴标签分别与它们的条不一致。 我怎样才能使每个X轴标签将在其酒吧之上? 提前致谢!

使用Swift 3自定义视图中的Google Maps绘制折线

我试图在自定义UIView上使用Google地图的两个地方之间绘制路线,但无法正确实施。 我的自定义视图是mapViewX。 我已经使用pod安装了Google sdk,其中包括pod“GoogleMaps”和pod“GooglePlaces”。 我把自定义类作为“GMSMapView”。 我的代码是: @IBOutlet weak var mapViewX: GMSMapView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let path = GMSMutablePath() path.add(CLLocationCoordinate2D(latitude: 37.778483, longitude: -122.513960)) path.add(CLLocationCoordinate2D(latitude: 37.706753, longitude: -122.418677)) let polyline = GMSPolyline(path: path) polyline.strokeColor = .black polyline.strokeWidth = 10.0 polyline.map = mapViewX […]

Stackview不附加第二个视图

我以编程方式创build了一个堆栈视图,并且添加了一个我已经以编程方式创build的视图。 但是,当我尝试添加第二个视图不起作用。 这是我的代码: @IBOutlet weak var codingScrollView: UIView! let codeStackView = UIStackView() var codeViews = [CodeView]() let codeView1 = CodeView(name: "Lennart", date: "13/05/2002", code: "Just some code") let codeView2 = CodeView(name: "Nina", date: "01/07/1999", code: "Also some code") codingScrollView是我添加到UIScrollView的contentview。 codeStackView是我之前描述的codeViews数组正在被用来添加视图到stackview。 这里是viewDidLoad方法: codeViews.append(codeView1) codeViews.append(codeView2) codingScrollView.addSubview(codeStackView) codingScrollView.backgroundColor = UIColor(red: 226/255, green: 226/255, blue: 226/255, alpha: 1) codeStackView.centerXAnchor.constraint(equalTo: […]