iphone - 如何将一个 AlertView 与另一个 AlertView 一起显示

标签 iphone objective-c ios

我想显示嵌套的alertView。我在嵌套alertViews中面临的问题是,当我单击第一个alertView的“添加”按钮时,它显示第二个alertView,在第二个alertView中我有一个文本字段和一个“保存”按钮。我想在单击保存按钮时保存数据,然后重新加载 UITableViewData,它已经在第一个alertView中。

我是 iPhone 新手,请帮助我。

最佳答案

您应该使用不同的 tag 属性创建警报 View ,以便在委托(delegate)方法中您可以轻松区分屏幕上显示的警报 View 。

例如:

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Info" 
  message:@"Message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];

[alert setTag: 1001]; // give different tag to different alert views
[alert show];
[alert release];

现在在委托(delegate)方法中:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if (alertView.tag == 1001)
   {
      // do something
   }
   eles if (alertView.tag == 1002)
   {
   }

}

希望对你有帮助..

关于iphone - 如何将一个 AlertView 与另一个 AlertView 一起显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8665986/

相关文章:

iphone - 使用两个谓词过滤数组

iOS - 解锁后第一个网络请求失败

iphone - 在 iPhone 上管理 HTTP Cookie

ios - 超链接按钮无响应 : iOS

ios - 在 iOS 11 中切换任务时出现虚假旋转事件

iphone - 第一次更改 View 的 layer.mask 后不会更新

iphone - UIViewContentModeScaleAspectFit 不适用于 UIScrollView subview UIImageView

php - 在 NSUserDefaults 中存储 swiftyJSON 返回的数据时出现问题...相同的数据源

ios - 根据字典键过滤 NSDictionary 的 NSArray

iphone - 内置点赞按钮 - Facebook SDK 3.0