gpt4 book ai didi

iphone - UIAlertView 不响应 UIAlertViewDelegate

转载 作者:行者123 更新时间:2023-12-03 20:28:57 25 4
gpt4 key购买 nike

我正在使用 iPhone 的 Logo (MobileSubstrate 插件),并为我的 .h 文件

@interface MyClass : NSObject <UIAlertViewDelegate>

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 0) {

在.m中,但没有任何作用,当点击警报上的按钮时,它不会调用我为每个buttonIndex设置的内容。

谢谢。

编辑:这就是我所得到的;

#import "Tweak.h"

%hook ASApplicationPageHeaderView

- (void)_showPurchaseConfirmation {
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:@"title"];
[alert setMessage:@"message"];
[alert setDelegate:self];
[alert addButtonWithTitle:@"button 1"];
[alert addButtonWithTitle:@"continue"];
[alert show];
[alert release];
}

- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) { //also tried (UIAlertView *)alertView
UIAlertView *lol = [[UIAlertView alloc] init];
[lol setTitle:@"button 1"];
[lol setMessage:@"button 1"];
[lol setDelegate:self];
[lol addButtonWithTitle:@"lol"];
[lol show];
[lol release];
} else {
%orig;
}
}

%end

最佳答案

您很可能需要在某个时候使用以下内容将您的类注册为委托(delegate):

 [yourAlertViewObject setDelegate:self];

作为UIAlertViewDelegate Protocol Reference文档说(强调我的):

If you add your own buttons or customize the behavior of an alert view, implement a delegate conforming to this protocol to handle the corresponding delegate messages. Use the delegate property of an alert view to specify one of your application objects as the delegate.

关于iphone - UIAlertView 不响应 UIAlertViewDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4907522/

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