-5
제 코드에서는 배열에 포인트를 만들고 그 배열을 사용하여 10 개의 버튼을 만들었습니다. 나는 각 버튼의 태그를 순서대로 0 - 9로 설정했다. 내가 할 수 있기를 원하는 것은 버튼이 미끄러 졌을 때 (단지 탭되지 않은) 확인한 다음 태그를 확인하고 태그가 무엇인지에 따라 무언가를 할 수 있는지 확인하는 것입니다.버튼이 미끄러 져 있는지 확인하고 태그를 확인하십시오. (iOS)
이 이사람이 좋은 방법을 알고 있나요
#import "LevelOneController.h"
@interface LevelOneController()
@end
@implementation LevelOneController
@synthesize whereStuffActuallyHappens, squareLocations;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"View loaded");
squareLocations = [[NSMutableArray alloc] init];
CGPoint dotOne = CGPointMake(1, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotOne]];
CGPoint dotTwo = CGPointMake(23, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotTwo]];
CGPoint dotThree = CGPointMake(45, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotThree]];
CGPoint dotFour = CGPointMake(67, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotFour]];
CGPoint dotFive = CGPointMake(89, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotFive]];
CGPoint dotSix = CGPointMake(111, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotSix]];
CGPoint dotSeven = CGPointMake(133, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotSeven]];
CGPoint dotEight = CGPointMake(155, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotEight]];
CGPoint dotNine = CGPointMake(177, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotNine]];
CGPoint dotTen = CGPointMake(199, 25);
[squareLocations addObject:[NSValue valueWithCGPoint:dotTen]];
int numby = [squareLocations count];
for (int i = 0; i < numby; i++)
{
NSValue *pointLocation = [squareLocations objectAtIndex:i];
CGPoint tmpPoint = [pointLocation CGPointValue];
UIImage *theSquare = [UIImage imageNamed:@"square.png"];
UIButton *squareButton = [[UIButton alloc] init];
squareButton = [UIButton buttonWithType:UIButtonTypeCustom];
squareButton.frame = CGRectMake(tmpPoint.x, tmpPoint.y, theSquare.size.width, theSquare.size.height);
squareButton.tag = *(&i);
[squareButton setImage:theSquare forState:UIControlStateNormal];
[whereStuffActuallyHappens addSubview:squareButton];
}
}
는이를 달성하기 :
여기 내 코드입니까? 감사!
죄송합니다 나는 일이 여기 실행 방법을 모르는 새로운 해요 –