Notes

メモ書き雑記ブログ(テニス・ガジェット・音楽活動など)

Top/Bottom layout guide が iOS 11.0 から Deprecated

こちらの Apple Developer Forums についてです。

iOS 11.0 に移行した際に発生するワーニング「Top/Bottom layout guide is deprecated since iOS 11.0」の発生と対処までのメモ書きです。

Xcode 8.3.3 でプロジェクト作成

Label配置

適当に Label を配置します。

f:id:cask-st:20170621220211p:plain

Constraint 設定

作成した Label に Constraint(制約)を設定。

ここでは Label の上側と左側に設定。

f:id:cask-st:20170621220216p:plain

Constraint 確認

きちんと Constraint(制約)が設定されていることを確認。

f:id:cask-st:20170621220220p:plain

 

Xcode 9.0 beta へ移行、ワーニング対処

次に 先ほど Xcode 8.3.3 で作成したプロジェクトを Xcode 9.0 beta で開きます。

Deployment Target 変更

Deployment Target を 11.0 に設定します。

f:id:cask-st:20170621220809p:plain

ビルド

この状態でビルドすると

Deprecated

Top layout guide is deprecated since iOS 11.0 

のワーニングが発生します。

f:id:cask-st:20170621220955p:plain

ワーニング解消

「Use Safe Area Layout Guides」にチェックを入れる。

再度ビルドするとワーニングが消えます。

f:id:cask-st:20170621221913p:plain

以上です。

DMM光(IPv6) & WN-AX1167GR が繋がらない?

スマフォがDMM Mobileなので、インターネットもDMM光にまとめた方がお得だろうということで変更しました。
(工事無料のキャンペーン中だったしということでw)

IPv4IPv6 があるとのことで、今後を考えるとIPv6かなぁということでIPv6を申込み。

今まで使っていたWi-FiルーターはIPv6未対応だったのでこの機会に買い替えました。
(10年くらい使ってた...w)

それがこちら↓
WN-AX1167GR
f:id:cask-st:20170604172118j:plain:w500
www.iodata.jp


工事後はプロバイダ等の設定なしで繋がるとのことで。
WN-AX1167GR 経由でPCをWi-Fi接続。

f:id:cask-st:20170604173440p:plain:w500

おお!ほんとに繋がった!超楽!!

さて、普通にネットサーフィンでもするか。

f:id:cask-st:20170604173444p:plain:w500

インターネットへアクセスできませんでした。

[かんたん設定]ボタンで設定を行ってください。

あれ??見れない。。

Googleのページが見れてるってことはプロバイダ関連ではない(まぁプロバイダ側もそう言ってるし)。
ということで、恐らく Wi-Fiルーター側の設定に問題があると睨んで調査。


結論から言うと、
Wi-Fiルーターのファームウェアを更新しなければならない
という話。

以下に書いてありました。
WN-AX1167GR 画面で見るマニュアル | アイ・オー・データ機器
引用:

①[ステータス]メニューの[ファームウェア]のバージョンを確認

ファームウェアのバージョンが[3.00]以下の場合は、ファームウェアを最新に更新する(「ファームウェアの更新手順」参照)

ファームウェアのバージョンが[3.10]以上の場合は、手順4へお進みください。

ファームウェアの更新をおこなった場合は、本製品を初期化し、インターネットにつなぎなおす(「出荷時設定へ戻す方法(初期化方法)」、「②スマホやPCをつなぐ」参照)

購入時は v2.00 だったので更新しなきゃだったー!


早速ファームウェア更新しました。

更新方法はこちらを参照。
http://www.iodata.jp/lib/manual/pdf2/wn-ax1167gr_wn-gx300gr_firmup.pdf


ファームウェアをダウンロードして、ルーター設定(http://192.168.0.1/index.htm)の
[システム設定] > [ファームウェア]
からファームウェア更新。

f:id:cask-st:20170604173455p:plain:w500


しばらく待ってファームウェア更新が完了したら、設定画面「インターネット」に「v6プラス」の項目が増えてるので、選択して設定。

f:id:cask-st:20170604173458p:plain:w500


以上でつながるようになりましたー!

[asin:B01BFW71HQ:detail]

UserNotifications Framework の Custom Action 実装方法

iOS10 から Notification がカスタマイズできるようになりました。
基本的に Notification の実装方法は Local and Remote Notification Programming Guide の通りなのですが、カスタマイズのやり方で一部記載されていない点があったのでメモ。

Custom Action を表示するために

Custom Action を表示するためには、
 1.Custom Action のカテゴリID
 2.表示するコンテンツのカテゴリID
を同一にする必要があるようです。
(同一でない場合は Custom Action のない通知が表示されました)
以下ソースコードになります。

環境 : Xcode 8.2.1 (iOS SDK 10.2) / シュミレータ

[Objective-C]

//  ViewController.h
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>

@interface ViewController : UIViewController <UNUserNotificationCenterDelegate>
@end
//  ViewController.m
#import "ViewController.h"

@interface ViewController ()
@end

/** カテゴリID */
static NSString *const CSKCategoryIdentifier = @"TEST_ACTIONS";

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"%s", __func__);
    
    // Notification のパーミッション許可要求
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
                          completionHandler:^(BOOL granted, NSError * _Nullable error)
    {
        if (granted) {
            // Notification のパーミッションが有効
        }
    }];
    
    // Delegate を設定
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
}

- (IBAction)registerLocalNotification:(UIButton *)sender {
    // カスタム Action を設定
    UNNotificationAction* noneAction = [UNNotificationAction
                                        actionWithIdentifier:@"NONE_ACTION"
                                        title:@"None"
                                        options:UNNotificationActionOptionNone];
    
    UNNotificationAction* destructiveAction = [UNNotificationAction
                                               actionWithIdentifier:@"DESTRUCTIVE_ACTION"
                                               title:@"Destructive"
                                               options:UNNotificationActionOptionDestructive];

    UNNotificationCategory* category = [UNNotificationCategory
                                        // 1.Custom Action のカテゴリID
                                        categoryWithIdentifier:CSKCategoryIdentifier
                                        actions:@[noneAction, destructiveAction]
                                        intentIdentifiers:@[]
                                        options:UNNotificationCategoryOptionNone];
    
    // NotificationCenter に カテゴリ を登録
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
    [center setNotificationCategories:[NSSet setWithObjects:category, nil]];

    // 通知するメッセージを設定
    UNMutableNotificationContent* content = [UNMutableNotificationContent new];
    content.title = [NSString localizedUserNotificationStringForKey:@"Title"
                                                          arguments:nil];
    content.body = [NSString localizedUserNotificationStringForKey:@"Body"
                                                         arguments:nil];
    content.subtitle = [NSString localizedUserNotificationStringForKey:@"Subtitle"
                                                             arguments:nil];
    content.sound = [UNNotificationSound defaultSound];
    // 2.表示するコンテンツのカテゴリID
    content.categoryIdentifier = CSKCategoryIdentifier;
    
    // 5秒後に通知するようにトリガーを設定
    UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger
                                                  triggerWithTimeInterval:5
                                                  repeats:NO];
    UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"Wait"
                                                                          content:content
                                                                          trigger:trigger];
    // Notification のリクエストを追加
    [center addNotificationRequest:request
             withCompletionHandler:^(NSError * _Nullable error)
    {
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end

で以下のようなカスタムアクションが表示されます。

f:id:cask-st:20170306223032p:plain