这是我的AlertView
代码:
- (void)initializeAlertControllerForOneButtonWithTitle:(NSString *)title withMessage:(NSString *)msg withYesButtonTitle:(NSString *)yesButtonTitle withYesButtonAction:(id)yesButtonAction
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:title
message:msg
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesBtn = [UIAlertAction
actionWithTitle:yesButtonTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (self.activityIndicator.animating) {
[self.activityIndicator stopAnimating];
}
if ([title isEqualToString:@"Wrong Password!"]) {
self.editTextField.text = @"";
[self.editTextField becomeFirstResponder];
}
}];
[alert addAction:yesBtn];
[self presentViewController:alert animated:YES completion:nil];
}
我正在尝试使用NSNotificatoin Response
方法触发此警报。我的Notification Response
代码:
- (void)receiveSMSVerificationResponse:(NSNotification *)notification
{
SMSVerificationDigitClassModel *smsVerificationDigitClassModel = [[SMSVerificationDigitClassModel alloc] init];
smsVerificationDigitClassModel = [notification object];
if (smsVerificationDigitClassModel.viewControllerName == ViewControllerNameProfileInfoEditViewController) {
if ([self alreadyRegisteredPhoneNumber:smsVerificationDigitClassModel.phoneNumber] == YES) {
NSLog(@"jogajog");
[self initializeAlertControllerForOneButtonWithTitle:@"Already Registered!" withMessage:kAlreadyRegisteredPhoneNumberMSGForChangePhoneNumber withYesButtonTitle:@"Ok" withYesButtonAction:nil];
} else {
if ([AdditionalClasses internetConnectionCheck] == YES) {
self.userModelClass.phone_number = smsVerificationDigitClassModel.phoneNumber;
[self updateUserModel:self.userModelClass];
} else {
[self noInternetConnectionAlert];
}
}
//Check if that phone number is already used
// udate phone numner in server
// update phone number in core data
//[self goToSignUpViewControllerWithPhoneNumber:smsVerificationDigitClassModel.phoneNumber];
}
}
我从断点检查它,此行[self initializeAlertControllerForOneButtonWithTitle:@"Already Registered!" withMessage:kAlreadyRegisteredPhoneNumberMSGForChangePhoneNumber withYesButtonTitle:@"Ok" withYesButtonAction:nil];
实际上正在调用,但警报视图没有弹出。它说:
“警告:尝试显示其视图不在窗口层次结构中!”
我尝试添加通知观察方法:
- (void)addNotificationObserver
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveUserModelResponse:) name:@"sendUpdateRequestToServerForPhoneNumberWithUserModel" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSMSVerificationResponse:) name:@"SMSVerificationForPhoneNumber" object:nil];
}
在viewDidLoad
,viewDidAppear
& viewWillAppear
中的removeObserver
和dealloc
中的- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"sendUpdateRequestToServerForPhoneNumberWithUserModel" object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"SMSVerificationForPhoneNumber" object:nil];
}
,
window hierarchy!
但根本没有显示。那么,如何更改此viewController
中的TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),'templates').replace('\\','/'),)
。如果您理解,请回复。非常感谢。
答案 0 :(得分:1)
在主队列调度队列块中调用initializeAlertControllerForOneButtonWithTitle方法。
所有用户界面操作都应该是主要威胁。
#include <string>
#include <list>
#include <memory>
#include <iostream>
class A
{ };
class B
{ };
template <typename>
struct specIndex
{ static constexpr std::size_t value { 0U }; }; // generic version
template <typename T>
struct specIndex<std::list<T> &>
{ static constexpr std::size_t value { 1U }; }; // pro lists
template <typename T>
struct specIndex<std::list<T> const &>
{ static constexpr std::size_t value { 1U }; }; // pro lists
template <typename T, std::size_t = specIndex<T>::value>
class C
{ };
template<typename T>
class C<T, 1U> : public A, public B
{
private:
T & l_ref;
public:
C (T & lr) : l_ref{lr}
{ std::cout << "- list version" << std::endl; }
};
int main ()
{
std::list<long> sll;
C<int> a;
C<std::list<long> &> b{sll};
C<std::list<long> const &> c{sll};
}