UIAlertViewポップアップの代わりになる電話くだ
-
20-09-2019 - |
質問
を取得しています奇行動からNSAlert二つの異なる部分のプログラム。の動作は:
- アラートが表示され、その 自然 消え去ります。
- アラートに戻しはで棄却されるすなわちユーザー通常の行動です。
- アラートも再現。
この挙動のみが発生し、初めての方法を表示するアラートが呼び出されます。その後初めてで動作します。
こちらのコードは、次のとおりです、部品の挙動が生じた
UIAlertView * locationAlert = [[UIAlertView alloc] initWithTitle:@"You are in the right place." message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[locationAlert show];
[locationAlert release];
または希望の場合はエリアを表示一部のエリアを表示コンテクスト:
- (IBAction)locateMe {
NSLog(@"About to check location");
locMan = [[CLLocationManager alloc] init];
locMan.delegate = self;
locMan.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
locMan.distanceFilter = 1609; //1 mile
[locMan startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation * )oldLocation {
if (newLocation.horizontalAccuracy >= 0) {
CLLocation *airportLocation = [[[CLLocation alloc] initWithLatitude:51.500148 longitude:-0.204669] autorelease];
CLLocationDistance delta = [airportLocation getDistanceFrom: newLocation];
long miles = (delta * 0.000621371) + 0.5; //metres to rounded mile
if (miles < 3) {
UIAlertView * locationAlert = [[UIAlertView alloc] initWithTitle:@"You are in the right place." message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[locationAlert show];
[locationAlert release];
[locMan stopUpdatingLocation];
} else {
UIAlertView * locationAlert = [[UIAlertView alloc] initWithTitle:@"You are not in the right place." message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[locationAlert show];
[locationAlert release];
[locMan stopUpdatingLocation];
}
}
}
- (void) locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
UIAlertView * locationAlert = [[UIAlertView alloc] initWithTitle:@"Error." message:error.code delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[locationAlert show];
[locMan release];
locMan = nil;
}
そのアイデア?感謝。
編集---------
その他の場所でこうです:
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSString * errorString = [NSString stringWithFormat:@"Unable to download feed from web site (Error code %i )", [parseError code]];
NSLog(@"error parsing XML: %@", errorString);
UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
コンテキストの場合は、AppDelegate、第二のコントローラー第1タブます。第二の問題が生じた時には、xmlではリローデッドがない場合に接続することができます。最初に発生した最初の時間の関数が呼び出されます。
編集-----
ま移動しアラートを出すことです。Unfortunatlyこないたいです!
- (IBAction)locateMe {
UIAlertView * locationAlert = [[UIAlertView alloc] initWithTitle:@"You are in the right place." message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[locationAlert show];
/*
NSLog(@"About to check location");
locMan = [[CLLocationManager alloc] init];
locMan.delegate = self;
locMan.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
locMan.distanceFilter = 1609; //1 mile
[locMan startUpdatingLocation];*/
}
更新:
私のものもセットNSLogエントリを発見したにもかかわらず、ほかの [locMan stopUpdatingLocation]
のdidUpdateToLocation機能を走ります。
しないといけないのではないか自然消失が起こるのでアラートのビューが再度呼び出されると、プログラムをクリアのインスタンスのための動します。
そのアイデアとしてなぜ [locMan stopUpdatingLocation]
あなたが働いただければ幸いですが、いかに移動宣言をlocationAlertの機能でグローバル)、セットアップすることができ、初期の探しい機能をご利用下時に呼ばれる:
[locationAlert show];
locationAlert = nil;
そのような作品です。
解決
と思いNSAlert 消滅 その解決です。
シンプルで明らかにしていくアラート表示は意外にするだれ誰にも予想できなかったしかし、そうでもないのでしょうかをプログラムに解任する警戒態勢にあるからです。何が原因で消滅する抗措置の発動表示。
デバッグであること:
(1)コードのNSAlert – dismissWithClickedButtonIndex:animated:
方法とを確認してくださいなんだかん実際に、一番のアラートプログラム.
(2)私はもはダブルチェックのことは一切っているアラートのビューが追加されたsubviewるいずれかの拠点は現在画面になります。このベースのビューが消える何らかの理由で、アラートビューです。の場合はビューが消え、その後再び急速に十分でない場合が明らかな場合、アラートを最前.(編集:参照編"マーティ-コメントします。)
(3)こう別のアプリを比較し両者の共通の要素構造です。共通要素ができるようになりました。奇問題です。
Edit01:更新のための追加情報
の場合 locMan
イーサーンインスタンス変数で定義すべきであるとして有すべきアクセスがゆきとself.locMan
アクセスするので、直接本体を万が一紛失してしまっ貴自動保存管理です。
他のヒント
しませんoff所長きに警戒態勢にあるからです。立地としては洗練された、デバイス(ieの精度が増し、コールバックする(潜在的に)と呼ばれます。のものを使用できる[locMan stopUpdatingLocation]後、アラート表示になります。
私のものもセットNSLogエントリを発見したにもかかわらず、ほかの[locMan stopUpdatingLocation】didUpdateToLocation機能を走ります。
しないといけないのではないか自然消失が起こるのでアラートのビューが再度呼び出されると、プログラムをクリアのインスタンスのための動します。
そのアイデアがなぜ[locMan stopUpdatingLocation]あなたが働いただければ幸いですが、いかに移動宣言をlocationAlertの機能でグローバル)、セットアップすることができ、初期の探しい機能をご利用下時に呼ばれる:
[locationAlert show];
locationAlert = nil;
そのような作品です。
また同じ問題を警告ダイアログに現れる、一瞬にreappearing、最後に再び登場後に棄却されてしまします。作っていただけるよう、文字列比較を決める前に、アラートビュー:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if([string isEqualToString:@"OK"]) {
NSLog(@"(Settings)Registration Successful");
statusField.text = @"Registration successful!";
[settingsActivity stopAnimating];
}
else {
NSLog(@"(Settings)Registration Failure");
[settingsActivity stopAnimating];
UIAlertView * regFail = [[[UIAlertView alloc] initWithTitle:@"Registration Error!" message:@"Please check your email address and try again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];
[regFail show];
}}
この行動だけどのような検証が返される文字列だけではなく、アラート:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if([string isEqualToString:@"OK"]) {
NSLog(@"(Settings)Registration Successful");
statusField.text = @"Registration successful!";
[settingsActivity stopAnimating];
}
else if([string isEqualToString:@"Error"]) {
NSLog(@"(Settings)Registration Failure");
[settingsActivity stopAnimating];
UIAlertView * regFail = [[[UIAlertView alloc] initWithTitle:@"Registration Error!" message:@"Please check your email address and try again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];
[regFail show];
}
私も同じ問題に取り組むと同時に、場所マネージャ。ここで確認でNslogで実行すが、最後に私は源泉と思を複数のオブジェクトを使用Sharedinstance同ViewControllerを含む所在地マネージャがいませんのオブジェクトで、perticular場所にどのように多くの物を作れていれば多くの時の位置検出するで取り組むと同時に、LocationMangerチェックを扱うオブジェを徹底的に削減これらのタイプの課題です。