我试图拨打一个不使用特定号码的号码,而是拨打变量中的号码,或者至少告诉它拨打手机中的号码.在变量中调用的这个数字是我使用解析器或从网站sql中获取的数字.我做了一个按钮试图通过功能调用存储在变量中的电话号码,但无济于事.什么都有帮助谢谢!
func callSellerPressed (sender: UIButton!){
//(This is calls a specific number)UIApplication.sharedApplication().openURL(NSURL(string: "tel://######")!)
// This is the code I'm using but its not working
UIApplication.sharedApplication().openURL(NSURL(scheme: NSString(), host: "tel://", path: busPhone)!)
}
Run Code Online (Sandbox Code Playgroud) 我一直在环顾四周,并没有看到任何快速相关的方法来做到这一点.我试图让我的UIWebViews高度变得动态.我有一个UIWebView使用loadHtmlString函数加载数据.事实是我从sqlite数据库加载数据,每次我加载不同长度的不同字符串,自然Web视图获得不同的高度.
现在我需要知道如何使UIWebView具有精确的高度,以便在webView下加载我的下一个内容.这就是我到目前为止所拥有的
var jobSkillView = UIWebView(frame: CGRectMake(-5, 480.0, screenWidth, 300.0))
jobSkillView.loadHTMLString("<html><body p style='font-family:arial;font-size:16px;'>" + jobSkills + "</body></html>", baseURL: nil)
jobSkillView.stringByEvaluatingJavaScriptFromString("document.body.innerHTML")
jobSkillView.scrollView.scrollEnabled = true
jobSkillView.scrollView.bounces = true
jobSkillView.sizeToFit()
border.addSubview(jobSkillView)
Run Code Online (Sandbox Code Playgroud)
我在SO上找到了这样的东西,但不知道如何将它链接到UIWebView框架:
func webViewDidFinishLoad(jobSkillView : UIWebView){
// Change the height dynamically of the UIWebView to match the html content
var jobSkillViewFrame: CGRect = jobSkillView.frame
jobSkillViewFrame.size.height = 1
jobSkillView.frame = jobSkillViewFrame
var fittingSize: CGSize = (jobSkillView.sizeThatFits(CGSizeZero))
jobSkillViewFrame.size = fittingSize
// webViewFrame.size.width = 276; Making sure that the webView doesn't get wider than …Run Code Online (Sandbox Code Playgroud) 我在班上打电话给代表时遇到了问题.我有一个SideBarTableController和SideBar.swift文件.它正常工作,直到我注销并重新进入.这是代码.它一直告诉我'ViewController'不符合协议'SideBarDelegate'.我是编程的新手,如果这很模糊,请提前对不起.什么都有帮助谢谢!
import UIKit
import iAd
class ViewController: UIViewController, SideBarDelegate { -----This is where the error is happening
@IBOutlet var menuTab: UIButton! // Menu Tab
@IBOutlet var businessButton: UIButton! // Business Button
@IBOutlet var adBanner: ADBannerView! // Banner Ad
@IBOutlet var imageView: UIImageView! // Main Image in middle
var topHeader: UIImageView! // Utility header
var sideBar:SideBar = SideBar() // Side Bar
override func viewDidLoad() {
super.viewDidLoad()
// Function for menu
// menuTab.addTarget(self, action: "buttonPressed", forControlEvents: UIControlEvents.TouchUpInside)
func menuTab(sender: UIButton){
sideBar = …Run Code Online (Sandbox Code Playgroud) 你怎么写这个?我在翻译时遇到了麻烦,因为swift是我的第一语言,这都是用Objective C.编写的.
UIScrollView * scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 3, scrollView.frame.size.height);
scrollView.delegate = self;
UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 90, scrollView.frame.size.width, 20)];
pageControl.numberOfPages = scrollView.contentSize.width/scrollView.frame.size.width;
[pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
Then you need to add the following two methods:
- (IBAction)changePage:(id)sender {
CGFloat x = pageControl.currentPage * scrollView.frame.size.width;
[scrollView setContentOffset:CGPointMake(x, 0) animated:YES];
}
-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSInteger pageNumber = roundf(scrollView.contentOffset.x / (scrollView.frame.size.width));
pageControl.currentPage = pageNumber;
Run Code Online (Sandbox Code Playgroud)