Tag: xcode

从资源加载JavaScript到UIWebView

我需要从我的应用程序资源文件夹加载JavaScript文件。 截至目前,它确实从资源中读取图像,但是由于某种原因,它并没有阅读javascripts。 我已经能够呈现html文档引用这些JavaScript如果HTML文件本身写入到资源,但我想通过设置一个UIWebView的HTML,因此它可以dynamic呈现HTML / JS。 这是我在做什么: NSString * html = @"<!DOCTYPE html><html><head><title>MathJax</title></head><body><script type=\"text/x-mathjax-config\">MathJax.Hub.Config({tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\(\",\"\\)\"]]}});</script><script type=\"text/javascript\" src=\"/MathJax/MathJax.js\"></script>$$\\int_x^yf(x) dx$$<img src=\"coffee.png\"></body></html>"; NSString * path = [[NSBundle mainBundle] resourcePath]; path = [path stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; path = [path stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; NSString * resourcesPath = [[NSString alloc] initWithFormat:@"file://%@/", path]; [webview loadHTMLString:html baseURL:[NSURL URLWithString:resourcesPath]]; 现在,如果我更改基本url到我的服务器也有所需的文件,它确实加载正确。 不需要互联网连接将是伟大的。 任何帮助表示赞赏! ;) 我发现这对获取图像显示很有用: iPhone […]

XCode有没有办法警告新的API调用?

不止一次,我发现在iOS 3.x上出现了崩溃的错误,因为使用了4.x中引入的新调用,而没有经过适当的检查。 有没有办法让XCode警告只有比部署目标更高版本的类,方法和过程? 这样我可以很容易地列出所有的代码,并确保它的条件化。

X,F,T,C,M,P,C,K,#等彩色框中字母的智能含义

最近,我开始使用Xcode 4开发iOS应用程序。 在Xcode intellisense的自动完成框中,每个build议前都有一些彩色框中的字母。 我知道它们代表了我们input的词的属性,如f,T,C,M,P,C,K,#等 是否有某种词汇表可用于查找其快速的含义? f,C,T,#的含义是可以理解的(函数,类等),但是还有许多我不知道的东西。 我假设这些字母是所有像Visual Studio,Netbeans等IDE的标准。纠正我,如果我错了。 请build议。

如何更改我的iOS应用程序的权利?

我需要运行下面的代码来closures我的iphone屏幕。 在iOS6上: void (*BKSDisplayServicesSetScreenBlanked)(BOOL blanked) = (void (*)(BOOL blanked))dlsym(RTLD_DEFAULT, "BKSDisplayServicesSetScreenBlanked"); 然后使用: BKSDisplayServicesSetScreenBlanked(1); // 1 to dim, 0 to undim 它不工作。 有人告诉我,我需要com.apple.backboard.client权利为此在我的iphone上工作。 我不知道如何设置这些权利。 我已经看到了设置权利的几种方式,但是像这样,我很困惑。 是的,您确实需要对权利进行编码签名。 但是,不,它不需要在越狱手机上获得苹果证书。 您可以通过下载ldid可执行文件来伪造代码签名,并执行此操作 cd MyAppName.app ldid -Sentitlements.xml MyAppName 假设您的应用程序名为MyAppName,并且您创build了权利文件entitlements.xml。 我相信,这个权利文件将为你工作,如果你假冒代码与ldid签名。 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.backboard.client</key> <true/> </dict> </plist> 即使有上述方法,我在哪里放置上述权利文件?

在xcode 5.1的Arm64架构

在新的XCode 5.1中,arm64已经成为构build的标准架构之一。 然而,在我目前的项目中,我包括了不支持这种新体系结构的图书馆(例如Google AdMob) – 这些现在导致链接器错误: ld: symbol(s) not found for architecture arm64 谷歌AdMob 6.8.0例如据说是支持arm64,但我不能确认这一点,除非cputype (16777228) cpusubtype (0)是arm64? (通过文件命令行工具find) libGoogleAdMobAds.a: Mach-O universal binary with 5 architectures libGoogleAdMobAds.a (for architecture armv7): current ar archive random library libGoogleAdMobAds.a (for architecture armv7s): current ar archive random library libGoogleAdMobAds.a (for architecture i386): current ar archive random library libGoogleAdMobAds.a (for […]

确定iOS设备上可用的RAM数量

你可能已经看到了许多“系统信息”应用程序,其中显示的东西,如电池剩余时间,甚至像内存等系统信息。 以类似的方式,有没有办法从我的应用程序检索当前可用的RAM的数量,以便我可以做出更好的决定,何时最好转储或保留某些视图以避免内存警告?

从命令行terminal创build带有位代码启用和位代码禁用的设备和通用configuration的iOS框架

#!/bin/sh UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal # make sure the output directory exists mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" # Step 1. Build Device and Simulator versions xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO \ -configuration ${CONFIGURATION} -sdk iphoneos \ BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} \ -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" \ BUILD_ROOT="${BUILD_ROOT}" clean build # Step 2. Copy the framework structure […]

AnyObject不工作在Xcode8 beta6?

在Xcode8 beta6中,下面的代码会导致警告:'是'testing总是如此。 但它不会打印通过。 struct TestStruct { } //warning: 'is' test is always true if TestStruct() is AnyObject { print("pass") } 下面的代码会引起警告:从'T'到'AnyObject'的条件转换总是成功的 public static func register<T>(_ protocolType: T.Type, observer: T) { //Warning: Conditional cast from 'T' to 'AnyObject' always succeeds guard let object = observer as? AnyObject else { fatalError("expecting reference type but found value type: […]

didSelectRowAtIndexPath不工作,Swift 3

任何人都可以看到为什么在世界didSelectRowAtIndexPath不会被称为? 我已经在代码和故事板中通过delegate进行三重检查。 class AddCard: UIViewController,UIPopoverPresentationControllerDelegate, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var cardView: UIView! @IBOutlet weak var tableView: UITableView! let tableItems = ["Background Color","Background Image","Font Style","Font Color"] let cellID = "cell" override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be […]

当单击DetailDesclosurebutton时MKAnnotationView推送到视图控制器

我想在我正在显示的地图上单击DetailDisclosure时切换视图。 我目前的代码如下: – (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; detailViewController.title = dictionary[@"placeLatitude"] [self.navigationController pushViewController:detailViewController animated:YES]; } 我可以推到视图控制器,但我还没有想出如何强制它从用于生成地图的JSON数组中的细节。 我拉这样的数据来生成地图: for (NSDictionary *dictionary in array) { // retrieve latitude and longitude from the dictionary entry location.latitude = [dictionary[@"placeLatitude"] doubleValue]; location.longitude = [dictionary[@"placeLongitude"] doubleValue]; //CAN I LOAD THE TITLE/ID OF […]