UIAlertView đại biểu "didDismissWithButtonIndex" được gọi mỗi khi u nhấp vào bất kỳ nút.
Hãy thử điều này:
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Message"
message:messageString
delegate:self
cancelButtonTitle:@"Back"
otherButtonTitles:@"Reply",@"Delete",nil];
[alert show];
[alert release];
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
{
NSLog(@"Reply");
UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"Button Clicked" message:@"U clicked Reply " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[myalert show];
[myalert release];
}
if (buttonIndex == 2)
{
NSLog(@"Delete");
UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"Button Clicked" message:@"U clicked Delete " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[myalert show];
[myalert release];
}
}
của nó không đồng bất cứ điều gì khi tôi nhấp vào bất kỳ những nút. – Ashutosh
tìm mã được cập nhật – iPhoneDev
Câu trả lời đúng. Mẹo: Đừng nhầm lẫn giữa 'didDismissWithButtonIndex' (được gọi * sau * UIAlertView rời khỏi hệ thống phân cấp màn hình) với' clicksButtonAtIndex' (được gọi trong khi UIAlertView vẫn còn trên màn hình và vẫn là một phần, và ảnh hưởng đáng kể đến cấu trúc phân cấp màn hình). Tôi đã tìm thấy kết hợp này trong các câu trả lời khác của StackOverflow và các địa điểm khác trên web. –