我在UIAlertView
中实施了viewDidLoad
。我选择alertView
(otherButton
)时试图buttonAtIndex:1
停留。这是我的代码:
UIAlertView *dialog = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message:"
delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Done", nil];
[dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];
[dialog show];
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) return;
[alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
}
当选择第二个按钮时("完成"),alertView
消失。我怎么能留下来?
答案 0 :(得分:2)
您应该创建自己的警报视图类,该类不是UIAlertView的子类。 UIAlertView的文档,它在'Subclassing notes:
下面说UIAlertView类旨在按原样使用,不支持子类化。 (...)
在UIAlertView
Apple Documentation标记为子类别备注
答案 1 :(得分:-1)
您可能拥有自己想要的内容here:
子类UIAlertView然后重载 -dismissWithClickedButtonIndex:animated :,例如
<Window x:Class="DataGridCellsBackground.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:local="clr-namespace:DataGridCellsBackground" >
<Grid>
<Grid.Resources>
<local:BoolToVis x:Key="BoolTovisibilityConverter"/>
</Grid.Resources>
<DataGrid SelectionUnit="Cell"
ItemsSource="{Binding items}"
AutoGenerateColumns="False">
<DataGrid.Resources>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Visible" Visibility="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=DataContext.ButtonIsVisible, Converter={StaticResource BoolTovisibilityConverter}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>