Objective c IOS 8目标反犹主义行动不起作用
我使用uibarbuttonim操作,它在ios 7上工作,而不是在ios 8上 在ios 7中,单击按钮后,cancelButtonPressed方法(在action中定义)正在运行,但在ios 8中没有发生任何事情cancelButtonPressed方法没有调用Objective c IOS 8目标反犹主义行动不起作用,objective-c,ios8,phonegap-plugins,Objective C,Ios8,Phonegap Plugins,我使用uibarbuttonim操作,它在ios 7上工作,而不是在ios 8上 在ios 7中,单击按钮后,cancelButtonPressed方法(在action中定义)正在运行,但在ios 8中没有发生任何事情cancelButtonPressed方法没有调用 id cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemIte
id cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancelButtonPressed:)
];
我在条形码扫描仪插件中使用它,它打开相机,在该屏幕中我有取消按钮:
- (UIView*)buildOverlayView {
if ( nil != self.alternateXib )
{
return [self buildOverlayViewFromXib];
}
CGRect bounds = self.view.bounds;
bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);
UIView* overlayView = [[[UIView alloc] initWithFrame:bounds] autorelease];
overlayView.autoresizesSubviews = YES;
overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
overlayView.opaque = NO;
UIToolbar* toolbar = [[[UIToolbar alloc] init] autorelease];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
id cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancelButtonPressed:)
];
//self.navigationItem.rightBarButtonItem=cancelButton;
id flexSpace = [[[UIBarButtonItem alloc] autorelease]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil
];
#if USE_SHUTTER
id shutterButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCamera
target:(id)self
action:@selector(shutterButtonPressed)
];
toolbar.items = [NSArray arrayWithObjects:flexSpace,cancelButton,flexSpace,shutterButton,nil];
#else
toolbar.items = [NSArray arrayWithObjects:flexSpace,cancelButton,flexSpace,nil];
#endif
bounds = overlayView.bounds;
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
CGFloat rootViewHeight = CGRectGetHeight(bounds);
CGFloat rootViewWidth = CGRectGetWidth(bounds);
CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);
[toolbar setFrame:rectArea];
[overlayView addSubview: toolbar];
UIImage* reticleImage = [self buildReticleImage];
UIView* reticleView = [[[UIImageView alloc] initWithImage: reticleImage] autorelease];
CGFloat minAxis = MIN(rootViewHeight, rootViewWidth);
rectArea = CGRectMake(
0.5 * (rootViewWidth - minAxis),
0.5 * (rootViewHeight - minAxis),
minAxis,
minAxis
);
[reticleView setFrame:rectArea];
reticleView.opaque = NO;
reticleView.contentMode = UIViewContentModeScaleAspectFit;
reticleView.autoresizingMask = 0
| UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleRightMargin
| UIViewAutoresizingFlexibleTopMargin
| UIViewAutoresizingFlexibleBottomMargin
;
[overlayView addSubview: reticleView];
return overlayView;
}
在ios8上使用它的替代方法是什么?您可能希望在类定义中使用全局变量或cancelButton的属性,而不是使用局部变量。我猜arc正在从内存中删除cancelButton。在第三个千年中,您是否仍然没有使用arc。启用ARC。2.使用现代Objective-C语法。3.参见1.快门按钮是否正常工作?如果只添加“取消”按钮而不添加其他内容,会发生什么情况?我正在使用条形码扫描仪插件,并且Arc被禁用,我没有找到任何使用Arc的ios条形码扫描仪。你认为这个问题与ARC有关吗?你能分享更多的代码和你在哪里初始化那个bar按钮吗,当我使用你的代码时,取消按钮方法在2分钟后立即被触发。我在这方面没有得到任何有用的东西,因此我可以纠正你的代码中出现的问题。IM使用条形码扫描仪插件,Arc被禁用。我没有找到任何使用Arc的ios条形码扫描仪。
remove autorelease and initialize bar button like that
id cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancelButtonPressed:)
];
self.navigationItem.rightBarButtonItem=cancelButton;