我有一个名为"buttonPressed"的按钮.当我按下按钮时,我需要找到该按钮的x和y坐标.你有什么想法可以帮助我吗?
UIButton *circleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
circleButton.frame = rect;
circleButton.layer.cornerRadius = 8.0f;
[circleButton addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[self addSubview:circleButton];
-(void)buttonPressed:(id)sender
{
}
Run Code Online (Sandbox Code Playgroud)
回答
- (IBAction)buttonPressed:(UIButton *)sender
{
CGPoint coordinates = sender.frame.origin;
CGFloat x = coordinates.x;
CGFloat y = coordinates.y;
}
Run Code Online (Sandbox Code Playgroud) 当我UIButton
一起点击这两个时,它同时打开.我的目的是当我点击单曲时UIButton
,其他人将无法点击.我认为这是关于多点触控功能.我只是想使用单点触控.
我的代码:
self.view.multipleTouchEnabled = false
self.view.exclusiveTouch = true
Run Code Online (Sandbox Code Playgroud)
我尝试了这段代码viewDidLoad
,但没有用.
我一直在观看如何制作想法游戏的教程.我注意到我不知道UIButton或Collection View是否是NSObject.该代码描述了一个NSArray,我想知道它如何与我的游戏的CollectionView和UIButton一起使用.
我想在我的ios项目中创建一个按钮.
此按钮适用于1到200(或任何以上)的计数
每次按下按钮,标签都会增加
第一次单击时,第二次单击时标签= 1,标签= 2...
我创建了一个按钮和一个标签.
按钮IBAction我该怎么办?
uibutton ×5
cocoa-touch ×3
ios ×3
objective-c ×2
button ×1
coordinate ×1
inheritance ×1
multi-touch ×1
swift ×1
tags ×1
uilabel ×1
xcode ×1