我想Top Layout Guide在UIScrollView直通自动布局中使用.没有UIScrollView自动布局可以很好地使用Top Layout Guide.

但是当我嵌入UIButton时UIScrollView,它没有.

我知道那是因为UIScrollView与层次结构级别不同Top Layout Guide.但我认为解决这个问题可能有一个很好的解决方案.
为什么iOS中的某些库提供了基于C的API?例如,Core Graphics库由基于C的API提供.但是,我无法理解Apple之所以这样做的原因.
而且,[[UIColor red] setStroke]drawRect中的那种代码:也让我感到困惑!如果Apple决定使用基于C的API,为什么他们使用面向对象的样式代码来做图形事情呢?
并且CGContextAddLineToPoint(),例如,进行论证CGContextRef c.我认为它完全适合使用面向对象的东西.
// current
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 10, 10);
// looks better
CGContext *context = [UIGraphics getCurrentContext]
[context moveToPoint: CGMakePoint(0, 0)] // or [context moveToPointX: 0 y: 0]
[context addLineToPoint: CGMakePoint(10, 10)] // or [context addLineToPointX: 10 y: 10]
Run Code Online (Sandbox Code Playgroud)
那么,为什么Apple在某些库上使用基于C的API?
我正在编写一个需要很多参数的注册方法.最初,我为我的方法选择了以下方法.
// APPROACH #1
- (void)signUpWithInformation:(NSDictionary *)information
success:(void (^)(NSDictionary *))success
failure:(void (^)(NSError *))failure
{
// ...
NSDictionary *parameters = @{@"email": information[@"email"],
@"new_password": information[@"password"],
@"user_name": information[@"username"],
@"sex": ([information[@"sex"] isEqualToNumber:@(EFTUserSexMale)]) ? @"M" : @"F",
@"phone_nubmer": information[@"phoneNumber"],
@"weight": information[@"weight"],
@"height": information[@"height"],
@"birthday": [formatter stringFromDate:information[@"birthday"]]};
// ...
}
Run Code Online (Sandbox Code Playgroud)
但我觉得这种方法有些不适.虽然information给了我一些灵活性,但它需要装箱和拆箱来将值存储到字典中.
所以我想到了以下方法.
// APPROACH #2
- (void)signUpWithEmail:(NSString *)email
password:(NSString *)password
name:(NSString *)name
sex:(EFTUserSex)sex
phoneNumber:(NSString *)phoneNumber
weight:(double)weight
height:(double)height
birthday:(NSDate *)birthday
success:(void (^)(NSDictionary *))success
failure:(void (^)(NSError *))failure
{
// ...
NSDictionary *parameters = @{@"email": email,
@"new_password": …Run Code Online (Sandbox Code Playgroud) 我想制作一个变量,这是客户想要的调味品.
我以为'condimentCustomerWants'没问题
但我永远不会在其他代码中看到包含相对代词的变量名.
所以我问我的朋友,他推荐'customerWantsCondiment',这是一句话.
嗯......哪个名字合适,好,可读?