cocoa-touch

Delete files from NSCachesDirectory programmatically

£可爱£侵袭症+ 提交于 2020-01-10 02:59:25
问题 If I downloaded files in NSCachesDirectory programmatically in my app, is it also possible to delete the files programmatically? 回答1: There may be many way for get full path of File from Directory , following is one of them. NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *mainPath = [myPathList objectAtIndex:0]; mainPath = [mainPath stringByAppendingPathComponent:DirectoryName]; Here mainPath is Full Path of File. NSFileManager

Smooth shape shift animation

。_饼干妹妹 提交于 2020-01-10 02:56:10
问题 How to shift shape (from oval to rect and vice versa) animated? Dirty code: UIBezierPath *roundedRectBezierPath = [UIBezierPath bezierPathWithRoundedRect:newRect cornerRadius:10]; UIBezierPath *ovalBezierPath = [UIBezierPath bezierPathWithOvalInRect:newRect]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"]; animation.duration = 3; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; if (isRect) { self.shapeLayer

Draw a line with a CALayer

こ雲淡風輕ζ 提交于 2020-01-09 19:31:07
问题 I'm trying to draw a line between two points using a CALayer. Here is my code: //positions a CALayer to be a line between a parent node and its subnodes. -(void)makeLineLayer:(CALayer *)layer lineFromPointA:(CGPoint)pointA toPointB:(CGPoint)pointB{ NSLog([NSString stringWithFormat:@"Coordinates: \n Ax: %f Ay: %f Bx: %f By: %f", pointA.x,pointA.y,pointB.x,pointB.y]); //find the length of the line: CGFloat length = sqrt((pointA.x - pointB.x) * (pointA.x - pointB.x) + (pointA.y - pointB.y) *

Draw a line with a CALayer

♀尐吖头ヾ 提交于 2020-01-09 19:27:07
问题 I'm trying to draw a line between two points using a CALayer. Here is my code: //positions a CALayer to be a line between a parent node and its subnodes. -(void)makeLineLayer:(CALayer *)layer lineFromPointA:(CGPoint)pointA toPointB:(CGPoint)pointB{ NSLog([NSString stringWithFormat:@"Coordinates: \n Ax: %f Ay: %f Bx: %f By: %f", pointA.x,pointA.y,pointB.x,pointB.y]); //find the length of the line: CGFloat length = sqrt((pointA.x - pointB.x) * (pointA.x - pointB.x) + (pointA.y - pointB.y) *

UIAlertView crashing on undocumented method

青春壹個敷衍的年華 提交于 2020-01-09 18:24:49
问题 Our app has been crashing with a frequency of roughly 1 in 1,500 launches due to a bug that is proving elusive. The relevant portion of the stack trace is included. It's being fired as a callback so I have no reference for where it's occurring in my own code. It looks like what's going on is there is a UIViewAnimationState object that is calling UIAlertView's private method ( _popoutAnimationDidStop:finished: ). Only problem is, it appears the UIAlertView has been dealloced by this point. I

UIAlertView crashing on undocumented method

*爱你&永不变心* 提交于 2020-01-09 18:23:42
问题 Our app has been crashing with a frequency of roughly 1 in 1,500 launches due to a bug that is proving elusive. The relevant portion of the stack trace is included. It's being fired as a callback so I have no reference for where it's occurring in my own code. It looks like what's going on is there is a UIViewAnimationState object that is calling UIAlertView's private method ( _popoutAnimationDidStop:finished: ). Only problem is, it appears the UIAlertView has been dealloced by this point. I

The exact moment iOS takes the view snapshot when entering background?

假如想象 提交于 2020-01-09 12:51:11
问题 I have a problem when putting my iPhone app to background by pushing the exit button, and then relaunching by tapping the launch icon on the home screen: the app's view does return to its initial state like I want it to, but before that it flashes the earlier, wrong view state onscreen briefly. Background My main view consists basically of a sequence of interlinked UIAnimateWithDuration calls. The behavior I want whenever any interruption occurs, is to reset the animation to its initial state

What is the purpose of using blocks

倾然丶 夕夏残阳落幕 提交于 2020-01-09 12:38:07
问题 I want to use blocks in my application, but I don't really know anything about blocks. Can anyone explain how and why I should use blocks in my code? 回答1: Blocks are closures (or lambda functions, however you like to call them). Their purpose is that using blocks, the programmer doesn't have to create named functions in the global scope or provide a target-action callback, instead he/she can create an unnamed, local "function" which can access the variables in its enclosing scope and easily

iOS 8.3 and later, Facebook share text not inserted

不想你离开。 提交于 2020-01-09 10:47:45
问题 After updating to iOS 8.3 the text is not inserted into the share dialog i use a standard UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:applicationActivities]; NSArray *excludeActivities = @[UIActivityTypeAssignToContact]; vc.excludedActivityTypes = excludeActivities; if (IsUserInterfaceIdiomPad) { vc.popoverPresentationController.sourceView = self.navigationController.view; } [self.navigationController presentViewController

Customize UISlider (track image height)

你说的曾经没有我的故事 提交于 2020-01-09 10:42:28
问题 I'm customizing a UISlider . I could set a custom thumb image that is higher than the usual thumb however I could not make the track higher when setting a higher minimum track image but the track height remained the same. It should be possible as in the iPod/Music App on the iPad the volume slider is also higher as the usual slider as you can see here: (source: cocoia.com) 回答1: You need to subclass the slider and override the trackRectForBounds: method, like this: - (CGRect)trackRectForBounds