我正在编写显示某些图片的应用程序,当用户点击图片时会调用某些功能
在纵向模式下,我将图像设置为可点击以大规模预览:
[imgv addTarget:self action:@selector(funShowPhoto) forControlEvents:UIControlEventTouchUpInside];
我希望在横向模式下跳过这个功能,我试试这个但是功能还在调用,我该怎么办?
[imgv addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
答案 0 :(得分:0)
只需在funShowPhoto
方法
-(void)funShowPhoto
{
// check if device is in portrait orientation
if([[UIDevice currentDevice]orientation] == UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown)
{
// run your code here device is in Portrait Mode
}
}
答案 1 :(得分:0)
您可以添加以前给出的代码Panayot Panayotov:
imgv.userInteractionEnabled = NO;
这样你就不必改变行动。
答案 2 :(得分:0)
- (void)viewDidLoad
{
UIButton *button_barcord = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // .....button_faves....
[button_barcord addTarget:self
action:@selector(bMethod:)
forControlEvents:UIControlEventTouchUpInside];
[button_barcord setBackgroundImage:[UIImage imageNamed:@"yourimag.png"] forState:UIControlStateNormal];
[button_barcord setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button_barcord.frame = CGRectMake(240,75,54,54);
[self.view addSubview:button_barcord];
[super viewDidLoad];
}
-(IBAction)bMethod:(id)sender
{
}