gpt4 book ai didi

objective-c - GCRectMake 的 iOS 错误 - 将 'int' 发送到不兼容类型 'CGRect' 的参数(又名 'struct CGRect')

转载 作者:可可西里 更新时间:2023-11-01 06:20:14 27 4
gpt4 key购买 nike

我是 iOS 编程新手。

我正在阅读一本指南,一本意大利语版的 iOS 书籍。对于第一个应用程序,我必须像这样修改 ViewController.m:

#import "ViewController.h"

@implementation ViewController

- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
// Release Any chached data, images, etc that aren't in use.
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)datiDettaglioChiudi:(datiDettaglio *)controller{
//altre operazioni possibii dopo la dismissModal
NSLog(@"... di ritorno dal DismissModal...");
[controller dismissViewControllerAnimated:YES completion:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"dettaglio"]){
datiDettaglio *mioController1 = segue.destinationViewController;
[mioController1 setDelegate:self];
//aggiunta di una UILabel - qui è possibile personalizzare la propria vista direttamente da codice
UILabel *testLabel = [[UILabel alloc] initWithFrame: GCRectMake(30,100,250,40)];
[testLabel setText:@"Etichetta di test"];
[testLabel setBackgroundColor:[UIColor greenColor]];
[testLabel setTextColor:[UIColor blackColor]];
[mioController1.view addSubview:testLabel];

}
}

- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
}


@end

问题出在这里:

UILabel *testLabel = [[UILabel alloc] initWithFrame: GCRectMake(30,100,250,40)];

GCRectMake 上:我有一个警告和一个错误:

WARNING Implicit declaration of function 'GCRectMake' is invalid in C99
ERROR Sending 'int' to parameter of incompatible type 'CGRect' (aka 'struct CGRect')

我真的不明白哪里出了问题。

最佳答案

CGRectMake,不是GCRectMake。 CG 代表核心图形。

关于objective-c - GCRectMake 的 iOS 错误 - 将 'int' 发送到不兼容类型 'CGRect' 的参数(又名 'struct CGRect'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14058342/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com