objective-c

Animating CALayer shadow simultaneously as UITableviewCell height animates

前提是你 提交于 2021-02-07 03:48:13
问题 I have a UITableView that I am attempting to expand and collapse using its beginUpdates and endUpdates methods and have a drop shadow displayed as that's happening. In my custom UITableViewCell, I have a layer which I create a shadow for in layoutSubviews : self.shadowLayer.shadowColor = self.shadowColor.CGColor; self.shadowLayer.shadowOffset = CGSizeMake(self.shadowOffsetWidth, self.shadowOffsetHeight); self.shadowLayer.shadowOpacity = self.shadowOpacity; self.shadowLayer.masksToBounds = NO;

NSURLConnection returning error instead of response for 401

╄→гoц情女王★ 提交于 2021-02-07 03:40:13
问题 I have a web API that, for a specific request returns status code 200 if everything went ok, and 401 if the user is not logged in based on an Authorization token. Everything works fine if the response status is 200, but doesn't seem to work properly if the response status is 401, returning a connection error with code -1012, while the response is nil. So, the following code: [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data,

NSURLConnection returning error instead of response for 401

你说的曾经没有我的故事 提交于 2021-02-07 03:39:09
问题 I have a web API that, for a specific request returns status code 200 if everything went ok, and 401 if the user is not logged in based on an Authorization token. Everything works fine if the response status is 200, but doesn't seem to work properly if the response status is 401, returning a connection error with code -1012, while the response is nil. So, the following code: [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data,

Can't add unified CNContact to CNGroup in iOS

半腔热情 提交于 2021-02-07 03:30:37
问题 Here's what I'm doing: - (void)doCreateGroup { [[self contentView] endEditing:true]; NSString * newString = [[[[self contentView] groupNameField] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString * firstError = nil; if ([newString length] == 0) { firstError = @"Missing group name"; } NSError * groupsError = nil; NSArray * groups = [self.contactStore groupsMatchingPredicate:nil error:&groupsError]; for (CNGroup * group in groups) { if ([group

Can't add unified CNContact to CNGroup in iOS

折月煮酒 提交于 2021-02-07 03:29:42
问题 Here's what I'm doing: - (void)doCreateGroup { [[self contentView] endEditing:true]; NSString * newString = [[[[self contentView] groupNameField] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString * firstError = nil; if ([newString length] == 0) { firstError = @"Missing group name"; } NSError * groupsError = nil; NSArray * groups = [self.contactStore groupsMatchingPredicate:nil error:&groupsError]; for (CNGroup * group in groups) { if ([group

CALayer frame origin.y is flipped, 0 is at the bottom?

99封情书 提交于 2021-02-07 03:09:36
问题 When I Add a set the fram on a CALayer the origin.y is reversed, 0 is at the bottom of it super layer and increasing origin.y moves it up in its super layer. Is there something I did to cause this to be flipped? I would expect origin.y=0 to be the top, not the bottom. Thanks, 回答1: You can flip the coordinate system to behave like iOS like this... layer.sublayerTransform = CATransform3DMakeScale(1.0f, -1.0f, 1.0f); 回答2: my two cents for UIViewController and swift: override func viewDidLoad() {

How to access rootViewController from React-Native

本小妞迷上赌 提交于 2021-02-07 01:23:28
问题 I'm creating React-Native module to access Admob. But the GADBannerView object requires rootViewController to perform. Do you know how to create react-native view/module to do it? Thank you very much. 回答1: From the native objective C code in your module, you can access the root view controller of the app as follows: UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController; 来源: https://stackoverflow.com/questions/29317190/how-to-access

How do I inject dependencies into an iOS view controller?

守給你的承諾、 提交于 2021-02-06 19:18:35
问题 My view controllers need to send messages to a couple of model objects. How do I obtain references to these model objects inside the view controller? These model objects are "singletons" (in that there should only be one copy of them in the system at once) and they are used by multiple view controllers. So I can't instantiate them in the init method of each view controller. I can't use constructor injection as the runtime chooses the init method that gets used to create the view controller. I

How do I inject dependencies into an iOS view controller?

孤人 提交于 2021-02-06 19:18:26
问题 My view controllers need to send messages to a couple of model objects. How do I obtain references to these model objects inside the view controller? These model objects are "singletons" (in that there should only be one copy of them in the system at once) and they are used by multiple view controllers. So I can't instantiate them in the init method of each view controller. I can't use constructor injection as the runtime chooses the init method that gets used to create the view controller. I

How do I inject dependencies into an iOS view controller?

﹥>﹥吖頭↗ 提交于 2021-02-06 19:16:38
问题 My view controllers need to send messages to a couple of model objects. How do I obtain references to these model objects inside the view controller? These model objects are "singletons" (in that there should only be one copy of them in the system at once) and they are used by multiple view controllers. So I can't instantiate them in the init method of each view controller. I can't use constructor injection as the runtime chooses the init method that gets used to create the view controller. I