Iphone 无法设置对象-找不到只读属性或setter
我无法简单地为UI按钮赋值:Iphone 无法设置对象-找不到只读属性或setter,iphone,objective-c,cocoa,cocoa-touch,iphone-sdk-3.0,Iphone,Objective C,Cocoa,Cocoa Touch,Iphone Sdk 3.0,我无法简单地为UI按钮赋值: //Assume rect is defined rect = CGRectMake(13, 10, 48, 48); profileButton = [[UIButton alloc] initWithFrame:rect]; profileButton.buttonType = UIButtonTypeCustom; 尝试将buttonType分配给UIButtonTypeCustom时,我得到“无法设置对象-找到只读属性或setter” 这是因为button
//Assume rect is defined
rect = CGRectMake(13, 10, 48, 48);
profileButton = [[UIButton alloc] initWithFrame:rect];
profileButton.buttonType = UIButtonTypeCustom;
尝试将buttonType分配给UIButtonTypeCustom时,我得到“无法设置对象-找到只读属性或setter” 这是因为
buttonType
是只读属性。您只能使用buttonwhithtype:
创建特定类型的按钮
profileButton = [[UIButton buttonWithType: UIButtonTypeCustom] retain];
profileButton.frame = CGRectMake(13, 10, 48, 48);
(不知道什么是
profileButton
,但假设它不是保留属性)这是因为buttonType
是只读属性。您只能使用buttonwhithtype:
创建特定类型的按钮
profileButton = [[UIButton buttonWithType: UIButtonTypeCustom] retain];
profileButton.frame = CGRectMake(13, 10, 48, 48);
(不知道什么是
profileButton
,但假设它不是保留属性)成功了。我需要在初始化时记住这一点。谢谢这就成功了。我需要在初始化时记住这一点。谢谢