【发布时间】:2015-02-23 12:49:59
【问题描述】:
在我的应用程序中包含 no.of UIElements,例如 facebook button, twitter button, logout button, imageview with gestures。
`
facebookBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[facebookBtn setImage:@"facebook.png"];
[facebookBtn addTarget:self action:@selector(switchToFacebookShare) forControlEvents:UIControlEventTouchUpInside];
[facebookBtn setFrame:CGRectMake(0, 50, 24, 24)];
[self.view addsubview:facebookBtn];`
`twitterBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[twitterBtn setImage:@"facebook.png"];
[twitterBtn addTarget:self action:@selector(switchToTwitterShare) forControlEvents:UIControlEventTouchUpInside];
[twitterBtn setFrame:CGRectMake(0, 100, 24, 24)];
[self.view addsubview:twitterBtn];`
`imageTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sectionTapping:)];
[imageTapGesture setNumberOfTapsRequired:1];`
`sectionPortraitImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[sectionPortraitImageView setUserInteractionEnabled:YES];
[sectionPortraitImageView addGestureRecognizer:imageTapGesture];
[contentView addSubview:sectionLandscapeImageView];`
像这样我添加了所有元素 当用户一次单击所有按钮时,所有三个功能都在工作。 这里只需要进行一项操作。
我该如何解决这个问题?
【问题讨论】:
-
在您的应用中,您在按钮中添加手势?
-
不,我只为图像视图添加了点击手势。当应用程序第一次启动时,然后如果我点击所有元素,所有元素都在执行
-
然后在此处添加您的一些代码。
-
在这里,我只能以编程方式添加按钮创建..
-
将
UIButton的exclusiveTouch属性设置为YES。
标签: ios user-interface uiimageview uibutton