-1
這是我創建的UIButton代碼,消息來禁用它
- (void) setNavButton
{
self->_newbutton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *myImage = [UIImage imageNamed:@"[email protected]"];
UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0, 46,57)] autorelease];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
[imageView.layer setMinificationFilter:kCAFilterTrilinear];
[imageView.layer setAllowsEdgeAntialiasing:YES];
CGRect imageRect = CGRectMake(0,0, imageView.bounds.size.width+10, imageView.bounds.size.height);
UIGraphicsBeginImageContextWithOptions(imageRect.size, NO, [UIScreen mainScreen].scale);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
[myImage drawInRect:CGRectMake(0,12,myImage.size.width,myImage.size.height)];
myImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[imageView setImage:myImage];
[self->_newbutton setImage:[imageView image] forState:UIControlStateNormal];
}
我創建屬性這一點,我訪問它在同一禁用它。但是,當這樣做,我得到和錯誤說'消息發送到一個釋放實例'。我正在使用下面的代碼來禁用它。
[self->_newbutton setEnabled:No];
任何原因爲'self - > _ newbutton'而不是'self._newbutton'? – zcui93
In class.h UIButton * _newbutton; @property(nonatomic,retain)UIButton * newbutton;×只有一個額外的 – Nikhil
閱讀關於目標C點語法,這不是C++訪問指針的方式。 – zcui93