Kri*_*utt 1 iphone alert confirmation uialertview ios4
基本上,我尝试做的是添加多个确认页...但我不能让它工作.无论我按什么确认,"继续"按钮都会导致完全相同的事情(没有文字的主体和带有"XXXX"的主题)...任何想法如何让confimationalerts导致不同的东西?
编辑2; 无论我按什么按钮(继续或解除),应用程序都会将用户发送到mail.app ...
-(IBAction)mail {
UIAlertView *mail = [[UIAlertView alloc] init];
[mail setTag:ALERTVIEW_MAIL_TAG];
[mail setTitle:@"Open mail"];
[mail setMessage:@"....."];
[mail setDelegate:self];
[mail addButtonWithTitle:@"Continue"];
[mail addButtonWithTitle:@"Dismiss"];
[mail show];
[mail release];
}
-(IBAction)feedback {
UIAlertView *feedback = [[UIAlertView alloc] init];
[feedback setTag:ALERTVIEW_TIPSA_TAG];
[feedback setTitle:@"Open mail"];
[feedback setMessage:@"....."];
[feedback setDelegate:self];
[feedback addButtonWithTitle:@"Continue"];
[feedback addButtonWithTitle:@"dismiss"];
[feedback show];
[feedback release];
}
- (void)showConfirmAlert
{
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if([alertView tag] == ALERTVIEW_FEEDBACK_TAG) {
NSURL *url = [[NSURL alloc] initWithString:@"mailto:?subject=XXXX"];
[[UIApplication sharedApplication] openURL:url];
[url release];
}
else if (buttonIndex == 1) {
}
else if ([alertView tag] == ALERTVIEW_MAIL_TAG) {
NSString *subject = @"YYYY";
NSString *body = @".....";
NSString *path = [NSString stringWithFormat:@"mailto:?subject=%@&body=%@", subject, body];
NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}
else if (buttonIndex == 1) {
}
}
Run Code Online (Sandbox Code Playgroud)
你需要设置tag你的UIAlertView目标和你的委托方法对它们进行切换,这就是为什么委托方法采用的UIAlertView,所以你可以基于按钮被按下哪个对象上做的东西.
#define ALERTVIEW_MAIL_TAG 100
#define ALERTVIEW_FEEDBACK_TAG 101
- (IBAction) feedback {
UIAlertView *feedback = [[UIAlertView alloc] init];
[feedback setTag:ALERTVIEW_FEEDBACK_TAG];
//...
}
- (IBAction) mail {
UIAlertView *mail = [[UIAlertView alloc] init];
[mail setTag:ALERTVIEW_MAIL_TAG];
}
-(void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger) buttonIndex {
if([alertView tag] == ALERTVIEW_MAIL_TAG) {
//do stuff...
} else {
//do other stuff...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2101 次 |
| 最近记录: |