gpt4 book ai didi

ios - 启用捏合以放大 View Controller

转载 作者:行者123 更新时间:2023-11-28 18:22:18 26 4
gpt4 key购买 nike

我希望用户能够使用双指缩放来放大我的应用程序,该应用程序使用 Storyboard 和以编程方式生成的按钮和标签在 Viewcontroller 中生成一个 View。在 View 的属性检查器中,我选中了 User Interaction EnabledMultiple Touch。但是缩放似乎不起作用。

创建 View 的重要部分的代码如下。

- (void)viewDidLoad
{
[super viewDidLoad];
NSInteger xPipsOrigin = 0;
NSInteger xPipsStep = 22.0;
NSString* cards = @"AKQJT98765432";
NSInteger yPipsOrigin = 100;

if (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone){
xPipsOrigin = 0;
xPipsStep = 22.0;
xPipsStep = 34.0;

}
else{
xPipsOrigin = 100;
xPipsStep = 40.0;
}
NSInteger xPipsCurrent = xPipsOrigin;

self.countCards = 0;

self.cardList = [NSMutableArray arrayWithCapacity:0];
yPipsOrigin = 100;
xPipsCurrent = xPipsOrigin;

for( int x=0;x<[cards length]; x++ ){
[cards substringWithRange:NSMakeRange(x,1)];
UIButton *b= [UIButton buttonWithType:UIButtonTypeRoundedRect];
xPipsCurrent += xPipsStep;
[b setTitle:[cards substringWithRange:NSMakeRange(x,1)] forState:UIControlStateNormal];
[b setTitle:@" " forState:UIControlStateDisabled];
[b setFrame:CGRectMake(xPipsCurrent, yPipsOrigin, 20, 20)];
[b setEnabled:YES];
[b setUserInteractionEnabled:YES];
[self.view addSubview:b];
[b addTarget:self action:@selector(spadeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

}

xPipsCurrent = xPipsOrigin + xPipsStep/2;
for( int x=0;x<[cards length]-1; x++ ){
xPipsCurrent += xPipsStep;
UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake( 0, 0, 20, 20)];
lab.text = @"\u2660";
lab.backgroundColor = [UIColor clearColor];
lab.center = CGPointMake(xPipsCurrent+10, yPipsOrigin+10);
[self.view addSubview:lab];
}

}

如何在此应用中启用双指缩放?

最佳答案

如果你想在 UIView 上启用缩放功能,你必须先将它包装到 UIScrollView

关于ios - 启用捏合以放大 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18105648/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com