cocoa-touch

How to synchronously animate a UIView and a CALayer

怎甘沉沦 提交于 2021-02-07 04:46:30
问题 To illustrate this question, I gisted a very small Xcode project on Github (two classes, 11kb download). Have a look at the gist here or use git clone git@gist.github.com:93982af3b65d2151672e.git . Please consider the following scenario. A custom view of mine, called 'container view', contains two little squares. Illustrated in this screenshot: The blue square is a 22x22 pt UIView instance and the red square is a 22x22 pt CALayer instance. For purposes of this question I want the two squares

Force MKMapView viewForAnnotation to update

断了今生、忘了曾经 提交于 2021-02-06 15:18:33
问题 So I have a MKMapView with all my pins added, and the colour of the pin is dependent on whether a value is set for that pin. When I first load the app, viewForAnnotation is called and the colours are set accordingly. However, when I update the pin's details (such as location, title, etc...) I also update the pinColour to find it doesn't update. It looks like viewForAnnotation isn't called again after the initial add. I have read many questions similar to this and I can confirm that mapView

Force MKMapView viewForAnnotation to update

安稳与你 提交于 2021-02-06 15:17:59
问题 So I have a MKMapView with all my pins added, and the colour of the pin is dependent on whether a value is set for that pin. When I first load the app, viewForAnnotation is called and the colours are set accordingly. However, when I update the pin's details (such as location, title, etc...) I also update the pinColour to find it doesn't update. It looks like viewForAnnotation isn't called again after the initial add. I have read many questions similar to this and I can confirm that mapView

Get difference between two dates?

前提是你 提交于 2021-02-05 12:13:11
问题 I have two dates in 24 hours formate like (dd-MMM-yyyy HH:mm). I want to get a difference between these two dates. My Code : This is getting only dates, I want a number of days and remaining time in hours also. (like 6days 5 hours) NSTimeInterval secondsBetween = [date2 timeIntervalSinceDate:date1]; int numberOfDays = secondsBetween / 86400; NSLog(@"There are %d days in between the two dates.", numberOfDays); 回答1: NSDateComponentsFormatter can do that NSTimeInterval secondsBetween = [date2

UIToolBar - disable buttons

為{幸葍}努か 提交于 2021-02-04 14:49:08
问题 in my app I have a toolbar and at a certain point I want to disable or enable some buttons. What is the easiest way to do so? How can I access items property of UIToolbar? Here is my code: -(void)addToolbar { NSMutableArray *buttons = [[NSMutableArray alloc] init]; //Define space UIBarButtonItem *flexibleSpaceItem; flexibleSpaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:nil action:NULL]; //Add "new" button UIBarButtonItem *newButton

Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?

*爱你&永不变心* 提交于 2021-01-29 22:56:05
问题 I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error. What does this mean? How can I fix it? *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.' 回答1: Your view controller may have the wrong class in your xib. I downloaded your project. The error you are getting is

Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?

☆樱花仙子☆ 提交于 2021-01-29 22:55:13
问题 I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error. What does this mean? How can I fix it? *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.' 回答1: Your view controller may have the wrong class in your xib. I downloaded your project. The error you are getting is

Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?

…衆ロ難τιáo~ 提交于 2021-01-29 22:52:51
问题 I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error. What does this mean? How can I fix it? *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.' 回答1: Your view controller may have the wrong class in your xib. I downloaded your project. The error you are getting is

Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?

♀尐吖头ヾ 提交于 2021-01-29 22:52:34
问题 I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error. What does this mean? How can I fix it? *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.' 回答1: Your view controller may have the wrong class in your xib. I downloaded your project. The error you are getting is

How do I change the text of a UILabel between each animation of animateWithDuration with repeat?

痞子三分冷 提交于 2021-01-28 19:34:55
问题 I have an Array words containing ["alice", "bob", "charles"] and a UILabel label . I want label to repeatedly fade in and out, with a different word from words each time. If I put the text-changing code inside the animations block, it doesn’t execute, even though the fading works as expected (the completion block is run only when something stops the repetition): label.alpha = 0 UIView.animateWithDuration(4, delay: 0, options: .Autoreverse | .Repeat, animations: { self.label.text = nextWord()