ライティングソフト ImgBurn
使い勝手が良い、ライティングソフト ImgBurnをインストールした時のメモ
本体のダウンロードページ
http://www.imgburn.com/index.php?act=download
日本語化パッチ
http://www.nihongoka.com/jpatch_main/imgburn/
参考
バックグラウンドで継続して処理を実行する
フォアグランドでダウンロードなどの処理をおこなっている最中に、バックグラウンドに回ってしまうと、通常は処理が中断してしまう。中断しないようにするにはどうすればいいか?
10分程度、処理の継続を許可してもらうような趣旨の実装。
@implementation ViewController { UIBackgroundTaskIdentifier bgid; } /********************************************************* ロード後 *********************************************************/ - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. /*-------------------------------------------- AppDelegeteに通知されるイベントを、 このオブジェクトでも通知を受信するように追加する ダウンロード中にバッググラウンドに移行すると処理が止まってしまう。 これを防ぐ為にバッグに移行したとき、バッグから復帰した時の処理を追加する *--------------------------------------------*/ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(willResignActive:) name:UIApplicationWillResignActiveNotification object:nil]; [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(didBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil]; } /********************************************************* アプリケーションがフォアグランドからバッググラウンドになる直前 *********************************************************/ - (void)willResignActive:(NSNotification *)notification { NSLog(@"resign"); UIApplication *app = UIApplication.sharedApplication; bgid = [app beginBackgroundTaskWithExpirationHandler:^{ [app endBackgroundTask:bgid]; bgid = UIBackgroundTaskInvalid; }]; } /********************************************************* アプリケーションがバッググラウンドからフォアグランドに復帰した直後 *********************************************************/ - (void)didBecomeActive:(NSNotification *)notification { NSLog(@"become"); [UIApplication.sharedApplication endBackgroundTask:bgid]; }
willResignActive、didBecomeActive の処理を、AppDelegate.m上で実装すれば、全てのView上の処理が、バックグランドに回っても中断されないようになるのかなぁ...?
参考
[Objective-C] バックグラウンドで継続して処理を実行する - Qiita
ローカル通知
通知を表示する為に、初回起動時に承認を行う
通知機能を使う為には #import <UserNotifications/UserNotifications.h> が必要となる。
AppDelegate.m #import <UserNotifications/UserNotifications.h> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //初回起動時、ユーザーの承認を得る UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge|UNAuthorizationOptionSound|UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (granted){ NSLog(@"承認された"); }else{ NSLog(@"承認されなかった"); } }]; }
通知を行う例
// 通知の表示 -(void)alertlocaNotification{ UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init]; content.title = [NSString localizedUserNotificationStringForKey:@"Hello!" //通知のタイトル(太字で表示される) arguments:nil]; content.body = [NSString localizedUserNotificationStringForKey:@"Hello_message_body" //通知のメッセージ(通常の文字で表示される) arguments:nil]; //content.sound = [UNNotificationSound defaultSound]; //通知の時、サウンドを鳴らすなら、有効にする // Deliver the notification in five seconds. UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 //何秒後に表示するか? repeats:NO]; //繰り返し通知するか? UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"TEST_ALERT_ID" content:content trigger:trigger]; // Schedule the notification. UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { }]; }
この例では、アプリがバックグランド状態でないと、通知されない。
フォアグランドでも表示させる方法もあるようだが、ViewControllerを指定する必要があるようだ。
参考
iOS 10 時代の Notification - Qiita
UIPickerView でコンボボックスみたいな。
#import "ViewController.h" @interface ViewController () //PickerをStoryBordを使わずに生成するので、デリゲート用のプロトコルを事前に宣言しておく <UITextFieldDelegate,UIPickerViewDelegate,UIPickerViewDataSource> { UIPickerView *testPickerView; } @property (weak, nonatomic) IBOutlet UITextField *textField1; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _textField1.delegate = self; testPickerView = [[UIPickerView alloc] init]; testPickerView.delegate = self; testPickerView.dataSource = self; testPickerView.showsSelectionIndicator = YES; testPickerView.backgroundColor = [UIColor magentaColor]; //PickerViewエリアの背景色 _textField1.inputView = testPickerView; //テキスト入力のキーボードに閉じるボタンを付ける // X,Y, witdh, height UIView* accessoryView =[[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,40)]; // 40:閉じるボタンのバーの高さ accessoryView.backgroundColor = [UIColor greenColor]; // 閉じるボタンエリアの背景色となる // ボタンを作成する。 UIButton* closeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // ボタンの位置 x= self.view.frame.size.width-100 とすることにより、右寄りに置いている // 位置を生成時に固定しているので、表示後に、縦横寸法が変わると、閉じるボタンが見えなくなってしまう closeButton.frame = CGRectMake(self.view.frame.size.width-100,10,100,20); [closeButton setTitle:@"close" forState:UIControlStateNormal]; //修正ここまで // クローズボタンを押したときによばれる動作を設定する。 [closeButton addTarget:self action:@selector(closeKeyboard:) forControlEvents:UIControlEventTouchUpInside]; // ボタンをViewに貼る [accessoryView addSubview:closeButton]; //accessoryViewをテキストフィールドに連結 _textField1.inputAccessoryView = accessoryView; /* hide undo, redo, paste button bar for textfield input view */ UITextInputAssistantItem* item = [_textField1 inputAssistantItem]; item.leadingBarButtonGroups = @[]; item.trailingBarButtonGroups = @[]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pickerView { return 3; //列数 } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return 10; //行数 } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { //ピッカーに表示する値 switch (component) { case 0: // 1列目 return [NSString stringWithFormat:@"%ld", (long)row]; break; case 1: // 2列目 return [NSString stringWithFormat:@"%ld", (long)row]; break; case 2: // 3列目 return [NSString stringWithFormat:@"%ld", (long)row]; break; default: return 0; break; } } //選択されたときのイベント - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSInteger val0 = [pickerView selectedRowInComponent:0]; // 1列目の選択された行数を取得 NSInteger val1 = [pickerView selectedRowInComponent:1]; // 2列目の選択された行数を取得 NSInteger val2 = [pickerView selectedRowInComponent:2]; // 3列目の選択された行数を取得 _textField1.text = [NSString stringWithFormat:@"%ld%ld%ld",(long)val0,(long)val1,(long)val2]; } //キーボードを閉じる -(void)closeKeyboard:(id)sender { //FirstResponderから外す [_textField1 resignFirstResponder]; } @end
これに、キャンセルボタン、Picker以外のオブジェクトがタップされたら、Pickerを消去できれば。。。
参考
UIPickerViewも下から出す。 | iPhoneアプリ備忘録
ios - UITextField inputView displays undo, redo, paste buttons - Stack Overflow
上部のステータスバーを非表示にする
//ViewController.m -(BOOL)prefersStatusBarHidden{ return YES; }
UITextView 初期表示で、先頭行が表示されない
目的のtextViewがAutoLayoutの対象になっており、viewDidLoadの後にtextViewの幅を調整するので、スクロールが動いてしまっていたようだ。
なので、レイアウト配置が終わった後のイベントで、スクロール位置を調整することにした。
-(void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; [self.txtTView setContentOffset:CGPointZero animated:NO]; }
参考
UITextView が初期表示時に勝手にスクロールする - Qiita
UIViewControllerのライフサイクル - Qiita