2
A
回答
0
使用自定義委託方法。 在自定義Alert類中聲明您的委託方法,並使用它傳遞數據。
在警報視圖類
Alert.h
@protocol AlertDelegate
- (void) setTxtValue:(NSSTring *)txtVal;
@end
@property (nonatomic, assign) <id> AlertDelegate *delegate;
@property (nonatomic, strong) NSSTring *getTxtVal;
@property (nonatomic, weak) UITextField *txtFld;
Alert.m
-(Void)viewDidLoad
{
txtFld.text = getTxtVal;
}
OK按鈕從任何視圖控制器
-(void)showAlert
{
Alert *alertObj = [[Alert alloc]init];
alertObj.delegate = self;
}
- (void) setTxtValue:(NSSTring *)txtVal
{
NSLog(@"entered Val: %@", txtVal);
}
希望這可以幫助你打電話給你的委託方法
-(void)OkClicked
{
[self.delegate setTxtValue: txtFld.text];
}
來電提示類。
相關問題
- 1. 如何從alertview
- 2. 如何檢查alertview值
- 3. 從alertview委託方法返回一個BOOL值: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- 4. 如何從WCF獲取,設置和返回值中獲取值?
- 5. 如何從MessageHeaderInfo獲取值
- 6. 如何從XML獲取值
- 7. 如何從Arraylist獲取值?
- 8. 如何從MyBatis獲取值?
- 9. 如何從ActionListener獲取值
- 10. 如何從timedelta獲取值?
- 11. 如何從json獲取值
- 12. 如何從屬性表中獲取值
- 13. 如何從PHP中獲取Android的值
- 14. 如何從服務中獲取值?
- 15. 如何從php數組中獲取值
- 16. 如何從XML樹中獲取值?
- 17. 如何從字符串中獲取值?
- 18. 如何從對象中獲取值
- 19. 如何在UIAlertView中從UITextField獲取值?
- 20. 如何從Android中的plist獲取值?
- 21. 如何從javascript ADF oracle中獲取值?
- 22. 如何從對象(stdClass)中獲取值?
- 23. 如何從Java中的JSONObject獲取值?
- 24. 如何在JSONARRAY中從JSONOBJECT獲取值?
- 25. 如何從SQL查詢中獲取值?
- 26. 如何從models.DateField ...中獲取Year值?
- 27. 如何從Dictionary中獲取MAX值?
- 28. 如何從JSON響應中獲取值
- 29. 如何從ListDown中的DropDownList獲取值?
- 30. 如何從對象中獲取值HtmlAttributes
檢查此(http://useyourloaf.com/blog/uialertcontroller-changes-in-ios-8.html) –
'UIAlertView'現在已被棄用。你現在應該使用'UIAlertController',正如@ ChintaN-Maddy-Ramani – danialzahid94
所提到的那樣,這個問題與iOS 6或以下版本無關,因此警報視圖工作正常。 –