iphone

How do I delay a for loop in swift without interrupting the main thread?

左心房为你撑大大i 提交于 2021-01-28 06:47:05
问题 I am trying to read through a string one character a time delaying .1 seconds before moving on to the next character. I have tried implementing the delay function inside the for loop but it has two problems. 1. The delay is inconsistent and does not take the same amount of time when moving between characters. 2. It disrupts the main thread which I think is the cause of the camera view freezing. However, I think it is also possible that activating the flashlight while the camera is on freezes

CLLocationManager is giving old location

╄→гoц情女王★ 提交于 2021-01-28 04:22:13
问题 In my header i put CLLocationManager *locationManager; @property (nonatomic, retain) CLLocationManager *locationManager; in my implementation file: - (void)viewDidLoad { self.locationManager = [[[CLLocationManager alloc] init] autorelease]; self.locationManager.distanceFilter = 50.0f; [self.locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; self.locationManager.delegate = self; [locationManager startUpdatingLocation]; [super viewDidLoad]; } then in the delegate method -

Stored properties cannot be marked potentially unavailable with '@available'

我是研究僧i 提交于 2021-01-28 02:37:19
问题 I found an interesting question about @available in Swift. I added a var "UISwipeActionsConfiguration" that supports iOS 11 and above to the TableView I encapsulated to support the left-slide edit and delete function of the list cell. I tried to imitate the writing of UITableView to decorate the Var, but the IDE directly compiles and reports an error. I can only try another set get method to decorate. I can't help but doubt how Apple's open source Swift source code is hidden. Compiled. Below

How to change nsstring to nsdate format in iphone?

半腔热情 提交于 2021-01-28 01:04:06
问题 I have struggling with to convert nsstring to nsdate format. I have a date in nsstring format like (2011-08-25 18:30:00 +0000), but i want to change it in nsdate format (08/26/2011). How to change it? Can any one help me please? Thanks in advance... I have spend one day to solve this but i cant find out the solution.. Please help me friends.... This is my code, NSString *dateString = @"2011-08-25 18:30:00 +0000"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter

Documents folder is empty in simulator. Where is my db.sqlite?

梦想的初衷 提交于 2021-01-28 00:58:00
问题 I read that I should find my sqlite db in this path: ~/Library/Application Support/iPhone Simulator/YOUR-IOS-VERSION/Applications/UNIQUE-KEY-FOR-YOUR-APP/Documents But the folder is empty. When I run my app in the simulator I am able to query the db. The db is originally located in the resources folder of my app. I am working with xcode 3.2.6 and OS X 10.6.8 IS there somewhere else where I could look for it? Many thanks. Lapo -(void)insertError:(Frage *) f answer2:(NSString *) answer2 answer3

dyld: Library not loaded: code signature invalid

痴心易碎 提交于 2021-01-28 00:41:18
问题 I'm trying to build and run an application that uses the AVFoundation framework ... ( I know that this is duplicate, but the solutions posted elsewhere don t help me.) I build successfully but the app crashes when I re-run it from Xcode with the following error: > dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib Referenced from : /private/var/containers/Bundle/Application/B9B93BB2-F55E-4DAE-A720-0F2D22A47278/FaceMarks.app/FaceMarks Reason: no suitable image found. Did find:

Swift assigning multiple classes to UI element

天大地大妈咪最大 提交于 2021-01-27 22:21:11
问题 Is it possible to assign multiple custom classes to the same UI Element in Swift? I have a UITextField that I need to animate with Spring(Animation library) and I also need to use some other library on the same UITextField that provides some other functionality. I usually assign the custom class in the identity inspector custom class section in the storyboard but I can't find a way to assign multiple classes. I also tried to create a new class and inherit from both of these libraries that I

Clickable Navbar title

心不动则不痛 提交于 2021-01-27 21:30:14
问题 How can I make the title of a navbar clickable. Much like in the facebook application. Were when you click it it dismisses the view controller. 回答1: set a UIButton as UINavigationItem's titleView .. add an action to that button.. for more details read UINavigationItem class reference 来源: https://stackoverflow.com/questions/3572346/clickable-navbar-title

How do I free() after malloc() when the result of malloc() is returned by the function?

心已入冬 提交于 2021-01-27 19:44:52
问题 I have the following instance method (adapted from Listing 3-6 of the Event Handling section in the iPhone Application Programming Guide): - (CGPoint)originOfTouch:(UITouch *)touch { CGPoint *touchOriginPoint = (CGPoint *)CFDictionaryGetValue(touchOriginPoints, touch); if (touchOriginPoint == NULL) { touchOriginPoint = (CGPoint *)malloc(sizeof(CGPoint)); // leaks CFDictionarySetValue(touchOriginPoints, touch, touchOriginPoint); *touchOriginPoint = [touch locationInView:touch.view]; } return

URLSession delegate function totalBytesExpectedToWrite always return -1

廉价感情. 提交于 2021-01-27 19:35:51
问题 I have created URLSession for downloading a file, File is being downloaded correctly no problem with that. I want to show the percentage count of remain bytes, but the delegate function: -(void) URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite and its parameter totalBytesExpectedToWrite always returns -1. All thing