我正在使用iPhone (MobileSubstrate插件)的徽标,以及我的.h文件
@interface MyClass : NSObject <UIAlertViewDelegate>
和
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(buttonIndex == 0) {
谢谢。
编辑:这是我得到的;
#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发布于 2011-02-05 23:03:36
在某些情况下,您很可能需要将您的类注册为委托,方法如下:
[yourAlertViewObject setDelegate:self];正如UIAlertViewDelegate Protocol Reference文档所说(强调我的):
如果您添加自己的按钮或自定义警报视图的行为,请实现符合此协议的委托来处理相应的委托消息。使用警报视图的delegate属性指定一个应用程序对象作为委派。
发布于 2011-02-06 00:14:23
在该类中定义您的警报,并将警报委托声明为self,希望它开始对您起作用
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert View "
"
message:@"Would you like to do something?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Button1", @"Button2", nil];
[alert show];
[alert release];发布于 2013-04-01 06:12:13
您只需将%new放在alertView委托的前面:
%new
-(void) alertView:...https://stackoverflow.com/questions/4907522
复制相似问题