searchDisplayController在iOS 8中已弃用

如何纠正以下内容,以免出现警告? 我错过了什么? 当更正searchResultsController searchController它给了我一个错误“找不到对象” if (tableView == self.searchDisplayController.searchResultsTableView) { cell.textLabel.text = [searchResults objectAtIndex:indexPath.row]; } else { cell.textLabel.text = [_content objectAtIndex:indexPath.row]; } return cell; } -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]]; return YES; }

在使用故事板的同时划分UIWindow

我有同样的问题在这个问题中解释: 我在哪里可以更改窗口我的应用程序使用从UIWindow到我自己的子类“MyWindow”故事板? 我的问题是我如何在我的应用程序委托,返回“MyWindow”子类实现“窗口”getter方法? 或者也许有其他的方法来分配我的子类到我的应用程序的主窗口?

如何从文件扩展名中拆分文件名在Swift中?

鉴于包中文件的名称,我想加载到我的Swift应用程序的文件。 所以我需要使用这个方法: let soundURL = NSBundle.mainBundle().URLForResource(fname, withExtension: ext) 无论出于何种原因,该方法需要从文件扩展名中分离出来的文件名。 很好,在大多数语言中很容易将两者分开。 但是到目前为止,我并没有发现它在Swift中是如此。 所以这里是我所拥有的: var rt: String.Index = fileName.rangeOfString(".", options:NSStringCompareOptions.BackwardsSearch) var fname: String = fileName .substringToIndex(rt) var ext = fileName.substringFromIndex(rt) 如果我不在第一行包括打字,我会在后面两行发现错误。 有了它,我得到了第一行的错误: Cannot convert the expression's type '(UnicodeScalarLiteralConvertible, options: NSStringCompareOptions)' to type 'UnicodeScalarLiteralConvertible' 我怎样才能从扩展名分割文件名? 有没有一些优雅的方式来做到这一点? 我对Swift感到兴奋,因为它好像比Objective C更优雅的语言。但现在我发现它有自己的麻烦。 第二次尝试:我决定做我自己的stringsearch方法: func rfind(haystack: String, needle: Character) -> Int { var […]

架构i386的未定义符号:“_OBJC_CLASS _ $ _ ZipException”,引用自:error

我在我的项目中使用了几个'.o'文件,并在编译时显示以下错误, error:linker command failed with exit code 1 (use -v to see invocation) 我发布了下面的错误日志 Ld /Users/deepak/Library/Developer/Xcode/DerivedData/app-bnwpvhpbrfdurbdgxucyddqyfosh/Build/Products/Debug-iphonesimulator/app.app/app normal i386 cd /Users/deepak/Workspace/iosDevelopement/PROJECTS/KML/app setenv IPHONEOS_DEPLOYMENT_TARGET 4.3 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -L/Users/deepak/Library/Developer/Xcode/DerivedData/app-bnwpvhpbrfdurbdgxucyddqyfosh/Build/Products/Debug-iphonesimulator -F/Users/deepak/Library/Developer/Xcode/DerivedData/app-bnwpvhpbrfdurbdgxucyddqyfosh/Build/Products/Debug-iphonesimulator -F/Users/deepak/Workspace/iosDevelopement/PROJECTS/KML/app -filelist /Users/deepak/Library/Developer/Xcode/DerivedData/app-bnwpvhpbrfdurbdgxucyddqyfosh/Build/Intermediates/app.build/Debug-iphonesimulator/app.build/Objects-normal/i386/app.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=4.3 -lstdc++ -licucore -lz -framework MapKit -framework CoreLocation -framework QuartzCore -framework […]

SBStatusBarController实例

有人可以帮我小样本如何获得SBStatusBarController实例吗? 我看了很多论坛和源代码,它不适合我:( 谢谢。

通过Objective-C创build一个SQLite3数据库文件

我试图在运行时通过Objective-C创build一个SQLite3数据库文件。 我正在尝试创build一个名为“tblStore”的表。 我希望字段名称被称为“strStoreNumber”和“strStoreReg”。 我是iOS和SQLite的新手,所以我很难find执行此操作的语法。 除了创build表格之外,我还希望创build的表格不驻留在应用程序包中,而是存放在手机的某处。 该表需要是可读/可写的。 我已经做了一些阅读“用户沙箱”和“文件目录”。 我不确定我是否了解两者之间的差异。 理想情况下,我的应用程序将使用一个button来从文本字段input。 在将来自文本字段的input放入string之后,将检查是否存在我的“tblStore”SQLite表,如果不存在,将创build表。 回顾一下:1.什么是Obj-C / SQLite创build一个名为“tblStore”的字段为“strStoreNumber”和“strStoreReg”的语法? 2.数据库文件应该放在哪里? 我需要读取和写入tblStore db文件。 3.“用户沙盒”和“文档目录”有什么不同? 这是我目前的: -(IBAction)setInput:(id)sender { NSString *strStoreNumber; NSString *strRegNumber; NSString *tableName = @"tblStore"; NSString *dbStrStore = @"strStore"; NSString *dbStrReg = @"strReg"; strStoreNumber = StoreNumber.text; strRegNumber = RegNumber.text; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* documentsDirectory = [paths lastObject]; NSString* databasePath […]

Map上的多个位置(使用MKMapItem和CLGeocoder)

我试图在MKMapItem显示多个位置。 我从CLGeocoder获取这些位置,不幸的是它只接受一个位置。 即使我通过一个NSArray它只是返回一个位置。 以下工作适用于单个位置,但不适用于多个位置。 我怎样才能对多个地点进行地理编码? Class mapItemClass = [MKMapItem class]; if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) { NSArray *addresses = @[@"Mumbai",@"Delhi","Banglore"]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:@[addresses] completionHandler:^(NSArray *placemarks, NSError *error) { CLPlacemark *geocodedPlacemark = [placemarks objectAtIndex:0]; MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:geocodedPlacemark.location.coordinate addressDictionary:geocodedPlacemark.addressDictionary]; MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark]; [mapItem setName:geocodedPlacemark.name]; [MKMapItem openMapsWithItems:@[mapItem] […]

iOS会在文本字段中自动添加连字符

我正在学习iOS开发,很难搞清楚控件的各种事件。 对于testing,我有一个UITextField,其中用户是要input一个string的格式:XXXX-XXXX-XXXX-XXXX 我希望能够检查每个条目之后字段中的文本的长度,并查看是否需要添加连字符。 我已经为此设置了我的IBAction函数,但是当我将其赋值给“Value Changed”事件时,它什么都不做,它在我编辑“Editing Did End”时工作正常,但只有当用户退出控制。 编辑:只需要添加,“编辑更改”事件导致它崩溃了。 我认为这是一个堆栈溢出或文本的设置再次调用事件处理程序的东西。 所以简而言之,每次用户在UITextField中input一个字符时,有没有办法设置一个事件处理程序呢?

Swift – 使用downloadTaskWithURL下载video

我正在下载一个video感谢downloadTaskWithURL,我保存到我的画廊与此代码: func saveVideoBis(fileStringURL:String){ print("saveVideoBis"); let url = NSURL(string: fileStringURL); (NSURLSession.sharedSession().downloadTaskWithURL(url!) { (location:NSURL?, r:NSURLResponse?, e:NSError?) -> Void in let mgr = NSFileManager.defaultManager() let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]; print(documentsPath); let destination = NSURL(string: NSString(format: "%@/%@", documentsPath, url!.lastPathComponent!) as String); print(destination); try? mgr.moveItemAtPath(location!.path!, toPath: destination!.path!) PHPhotoLibrary.requestAuthorization({ (a:PHAuthorizationStatus) -> Void in PHPhotoLibrary.sharedPhotoLibrary().performChanges({ PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(destination!); }) { completed, error in […]

iOS无法识别的select器发送到Swift中的实例

我有问题试图让用户按下它的UIButton工作。 我不断收到一个错误说:无法识别的select器发送到实例 override func viewDidLoad() { super.viewDidLoad() button.addTarget(self, action: "buttonClick", forControlEvents: UIControlEvents.TouchUpInside) button.setTitle("Print", forState: UIControlState.Normal) button.font = UIFont(name: "Avenir Next", size: 14) button.backgroundColor = UIColor.lightGrayColor() self.view.addSubview(button) } func buttonClick(Sender: UIButton!) { myLabelInfo.text = "Hello" } 对于诸如func buttonClick(Sender: UIButton)的Swift方法,要传递给select器的addTarget方法的正确string是什么? 是“buttonClick”,“buttonClick:”,“buttonClickSender:”还是别的?