質問編集履歴
31
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,10 +36,6 @@
|
|
36
36
|
|
37
37
|
```Swiift
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
39
|
import UIKit
|
44
40
|
|
45
41
|
|
@@ -64,7 +60,7 @@
|
|
64
60
|
|
65
61
|
|
66
62
|
|
67
|
-
|
63
|
+
var nextimage: UIImage!
|
68
64
|
|
69
65
|
|
70
66
|
|
@@ -112,6 +108,10 @@
|
|
112
108
|
|
113
109
|
|
114
110
|
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
115
|
override func viewDidLoad() {
|
116
116
|
|
117
117
|
|
@@ -278,15 +278,73 @@
|
|
278
278
|
|
279
279
|
isSuccses = true
|
280
280
|
|
281
|
+
|
282
|
+
|
281
|
-
let manager = PHImageManager.default()
|
283
|
+
let manager = PHImageManager.default()
|
282
|
-
|
284
|
+
|
285
|
+
|
286
|
+
|
283
|
-
manager.requestImage(for: asset, targetSize: CGSize(width:100, height:100),
|
287
|
+
manager.requestImage(for: asset, targetSize: CGSize(width: 100, height: 100),
|
284
|
-
|
288
|
+
|
289
|
+
|
290
|
+
|
285
|
-
contentMode:
|
291
|
+
contentMode: .aspectFill, options: nil){
|
286
|
-
|
292
|
+
|
293
|
+
|
294
|
+
|
287
|
-
(image, info) -> Void in
|
295
|
+
(image, info) -> Void in
|
296
|
+
|
297
|
+
|
298
|
+
|
288
|
-
|
299
|
+
self.nextimage = image
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
289
|
-
}
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
})
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
if isSuccses{
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
self.performSegue(withIdentifier: "toViewController2", sender: nil)
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
} else if (TextField.text! == "" ){
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
alert2(title: "", message: "")
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
} else {
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
alert1(title: "",message: "")
|
290
348
|
|
291
349
|
|
292
350
|
|
@@ -294,35 +352,183 @@
|
|
294
352
|
|
295
353
|
|
296
354
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
if
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
if segue.identifier == "toViewController2"{
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
let nextVC = segue.destination as! ViewController2
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
nextVC.image = self.nextimage
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
@IBOutlet weak var TextField: UITextField!
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
@IBAction func Button(_ sender: UIButton) {
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
getAllPhotosInfo()
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
}
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
self.view.endEditing(true)
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
}
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
TextField.resignFirstResponder()
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
return true
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
}
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
```
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
```swift
|
470
|
+
|
471
|
+
import UIKit
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
class ViewController2: UIViewController {
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
@IBOutlet weak var imageView: UIImageView!
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
var image: UIImage!
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
var nextVC: UIImage!
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
var timer:Timer = Timer()
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
override func viewDidLoad() {
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
super.viewDidLoad()
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
imageView.image = nextVC
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
// Do any additional setup after loading the view.
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
timer = Timer.scheduledTimer(timeInterval: 5.0,target: self,selector: #selector(changeView),userInfo: nil,repeats: false)
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
326
532
|
|
327
533
|
|
328
534
|
|
@@ -330,198 +536,46 @@
|
|
330
536
|
|
331
537
|
|
332
538
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
TextField.resignFirstResponder()
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
}
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
return true
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
}
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
}
|
539
|
+
override func didReceiveMemoryWarning() {
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
super.didReceiveMemoryWarning()
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
// Dispose of any resources that can be recreated.
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
@objc func changeView() {
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
self.navigationController?.popToRootViewController(animated: true)
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
}
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
}
|
418
580
|
|
419
581
|
```
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
```swift
|
424
|
-
|
425
|
-
import UIKit
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
class ViewController2: UIViewController {
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
@IBOutlet weak var imageView: UIImageView!
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
var image: UIImage!
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
var timer:Timer = Timer()
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
override func viewDidLoad() {
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
super.viewDidLoad()
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
imageView.image = image
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
// Do any additional setup after loading the view.
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
timer = Timer.scheduledTimer(timeInterval: 5.0,target: self,selector: #selector(changeView),userInfo: nil,repeats: false)
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
}
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
override func didReceiveMemoryWarning() {
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
super.didReceiveMemoryWarning()
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
// Dispose of any resources that can be recreated.
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
}
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
@objc func changeView() {
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
self.navigationController?.popToRootViewController(animated: true)
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
}
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
}
|
526
|
-
|
527
|
-
```
|
30
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -278,6 +278,16 @@
|
|
278
278
|
|
279
279
|
isSuccses = true
|
280
280
|
|
281
|
+
let manager = PHImageManager.default()
|
282
|
+
|
283
|
+
manager.requestImage(for: asset, targetSize: CGSize(width:100, height:100),
|
284
|
+
|
285
|
+
contentMode: .aspectFill, options: nil) {
|
286
|
+
|
287
|
+
(image, info) -> Void in
|
288
|
+
|
289
|
+
}
|
290
|
+
|
281
291
|
|
282
292
|
|
283
293
|
}
|
@@ -328,92 +338,190 @@
|
|
328
338
|
|
329
339
|
|
330
340
|
|
341
|
+
@IBOutlet weak var TextField: UITextField!
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
331
|
-
|
349
|
+
@IBAction func Button(_ sender: UIButton) {
|
350
|
+
|
351
|
+
|
352
|
+
|
332
|
-
|
353
|
+
getAllPhotosInfo()
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
333
|
-
|
369
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
self.view.endEditing(true)
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
TextField.resignFirstResponder()
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
return true
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
334
414
|
|
335
415
|
|
336
416
|
|
337
417
|
}
|
338
418
|
|
339
|
-
|
340
|
-
|
341
|
-
@IBOutlet weak var TextField: UITextField!
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
@IBAction func Button(_ sender: UIButton) {
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
getAllPhotosInfo()
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
self.view.endEditing(true)
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
TextField.resignFirstResponder()
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
}
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
return true
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
}
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
}
|
418
|
-
|
419
419
|
```
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
```swift
|
424
|
+
|
425
|
+
import UIKit
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
class ViewController2: UIViewController {
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
@IBOutlet weak var imageView: UIImageView!
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
var image: UIImage!
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
var timer:Timer = Timer()
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
override func viewDidLoad() {
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
super.viewDidLoad()
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
imageView.image = image
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
// Do any additional setup after loading the view.
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
timer = Timer.scheduledTimer(timeInterval: 5.0,target: self,selector: #selector(changeView),userInfo: nil,repeats: false)
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
override func didReceiveMemoryWarning() {
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
super.didReceiveMemoryWarning()
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
// Dispose of any resources that can be recreated.
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
@objc func changeView() {
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
self.navigationController?.popToRootViewController(animated: true)
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
}
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
}
|
526
|
+
|
527
|
+
```
|
29
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -330,7 +330,7 @@
|
|
330
330
|
|
331
331
|
let manager = PHImageManager.defaultManager()
|
332
332
|
|
333
|
-
manager.requestImageForAsset(asset, contentMode: .AspectFill, options: nil) { (image, info) in
|
333
|
+
func manager;.requestImageForAsset(asset, contentMode: .AspectFill, options: nil) { (image, info) in
|
334
334
|
|
335
335
|
|
336
336
|
|
28
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -328,7 +328,13 @@
|
|
328
328
|
|
329
329
|
|
330
330
|
|
331
|
-
|
331
|
+
let manager = PHImageManager.defaultManager()
|
332
|
+
|
333
|
+
manager.requestImageForAsset(asset, contentMode: .AspectFill, options: nil) { (image, info) in
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
}
|
332
338
|
|
333
339
|
|
334
340
|
|
27
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -264,7 +264,7 @@
|
|
264
264
|
|
265
265
|
|
266
266
|
|
267
|
-
let name: String = asset
|
267
|
+
let name: String = asset.value(forKey: "filename")as! String
|
268
268
|
|
269
269
|
|
270
270
|
|
26
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,46 +38,84 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
+
|
42
|
+
|
41
43
|
import UIKit
|
42
44
|
|
45
|
+
|
46
|
+
|
43
47
|
import Photos
|
44
48
|
|
45
49
|
|
46
50
|
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
47
55
|
class ViewController: UIViewController,UITextFieldDelegate{
|
48
56
|
|
49
57
|
|
50
58
|
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
51
63
|
var alertController: UIAlertController!
|
52
64
|
|
53
65
|
|
54
66
|
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
55
71
|
func alert1(title:String,message:String){
|
56
72
|
|
73
|
+
|
74
|
+
|
57
75
|
alertController = UIAlertController(title: "データが存在しません", message: "", preferredStyle: UIAlertController.Style.alert)
|
58
76
|
|
77
|
+
|
78
|
+
|
59
79
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
60
80
|
|
81
|
+
|
82
|
+
|
61
83
|
present(alertController, animated: true)
|
62
84
|
|
85
|
+
|
86
|
+
|
63
|
-
}
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
64
92
|
|
65
93
|
|
66
94
|
|
67
95
|
func alert2(title:String,message:String){
|
68
96
|
|
97
|
+
|
98
|
+
|
69
99
|
alertController = UIAlertController(title: "データを入力してください", message: "", preferredStyle: UIAlertController.Style.alert)
|
70
100
|
|
101
|
+
|
102
|
+
|
71
103
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
72
104
|
|
105
|
+
|
106
|
+
|
73
107
|
present(alertController, animated: true)
|
74
108
|
|
109
|
+
|
110
|
+
|
75
111
|
}
|
76
112
|
|
77
113
|
|
78
114
|
|
79
115
|
override func viewDidLoad() {
|
80
116
|
|
117
|
+
|
118
|
+
|
81
119
|
super.viewDidLoad()
|
82
120
|
|
83
121
|
|
@@ -88,126 +126,288 @@
|
|
88
126
|
|
89
127
|
libraryRequestAuthorization()
|
90
128
|
|
129
|
+
|
130
|
+
|
91
131
|
TextField.delegate = self
|
92
132
|
|
133
|
+
|
134
|
+
|
93
135
|
TextField.layer.borderWidth = 1.5
|
94
136
|
|
137
|
+
|
138
|
+
|
95
139
|
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 8, height: 5))
|
96
140
|
|
141
|
+
|
142
|
+
|
97
143
|
TextField.leftView = paddingView
|
98
144
|
|
145
|
+
|
146
|
+
|
99
147
|
TextField.leftViewMode = .always
|
100
148
|
|
149
|
+
|
150
|
+
|
101
151
|
self.view.addSubview(TextField)
|
102
152
|
|
153
|
+
|
154
|
+
|
103
|
-
}
|
155
|
+
}
|
104
|
-
|
105
|
-
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
106
162
|
|
107
163
|
override func didReceiveMemoryWarning() {
|
108
164
|
|
165
|
+
|
166
|
+
|
109
167
|
super.didReceiveMemoryWarning()
|
110
168
|
|
169
|
+
|
170
|
+
|
111
|
-
}
|
171
|
+
}
|
112
|
-
|
113
|
-
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
114
178
|
|
115
179
|
fileprivate func libraryRequestAuthorization() {
|
116
180
|
|
181
|
+
|
182
|
+
|
117
183
|
PHPhotoLibrary.requestAuthorization({status in
|
118
184
|
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
119
191
|
switch status {
|
120
192
|
|
193
|
+
|
194
|
+
|
121
195
|
case .authorized:
|
122
196
|
|
197
|
+
|
198
|
+
|
123
199
|
self.getAllPhotosInfo()
|
124
200
|
|
201
|
+
|
202
|
+
|
125
203
|
case .denied:
|
126
204
|
|
205
|
+
|
206
|
+
|
127
207
|
print("拒否されました")
|
128
208
|
|
209
|
+
|
210
|
+
|
129
211
|
case .notDetermined:
|
130
212
|
|
213
|
+
|
214
|
+
|
131
215
|
print("決まっていない")
|
132
216
|
|
217
|
+
|
218
|
+
|
133
219
|
case .restricted:
|
134
220
|
|
221
|
+
|
222
|
+
|
135
223
|
print("制限あり")
|
136
224
|
|
225
|
+
|
226
|
+
|
137
227
|
@unknown default:
|
138
228
|
|
229
|
+
|
230
|
+
|
139
231
|
return
|
140
232
|
|
233
|
+
|
234
|
+
|
141
235
|
}
|
142
236
|
|
237
|
+
|
238
|
+
|
143
239
|
})
|
144
240
|
|
241
|
+
|
242
|
+
|
145
|
-
}
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
146
248
|
|
147
249
|
|
148
250
|
|
149
251
|
fileprivate func getAllPhotosInfo(){
|
150
252
|
|
253
|
+
|
254
|
+
|
151
|
-
let assets
|
255
|
+
let assets = PHAsset.fetchAssets(with: .image, options: nil)
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
var isSuccses: Bool = false
|
260
|
+
|
261
|
+
|
152
262
|
|
153
263
|
assets.enumerateObjects({ asset, _, _ in
|
154
264
|
|
265
|
+
|
266
|
+
|
155
|
-
|
267
|
+
let name: String = assets.value(forKey: "filename")as! String
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
if (self.TextField.text == name){
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
isSuccses = true
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
156
286
|
|
157
287
|
})
|
158
288
|
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
if isSuccses{
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
} else if (TextField.text! == "" ){
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
alert2(title: "", message: "")
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
} else {
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
alert1(title: "",message: "")
|
316
|
+
|
317
|
+
|
318
|
+
|
159
|
-
}
|
319
|
+
}
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
160
|
-
|
327
|
+
}
|
161
|
-
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
162
334
|
|
163
335
|
@IBOutlet weak var TextField: UITextField!
|
164
336
|
|
165
337
|
|
166
338
|
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
@IBAction func Button(_ sender: UIButton) {
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
getAllPhotosInfo()
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
167
363
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
168
364
|
|
365
|
+
|
366
|
+
|
169
367
|
self.view.endEditing(true)
|
170
368
|
|
369
|
+
|
370
|
+
|
171
|
-
}
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
172
376
|
|
173
377
|
|
174
378
|
|
175
379
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
176
380
|
|
381
|
+
|
382
|
+
|
177
383
|
TextField.resignFirstResponder()
|
178
384
|
|
385
|
+
|
386
|
+
|
179
|
-
}
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
180
392
|
|
181
393
|
|
182
394
|
|
183
395
|
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
184
396
|
|
397
|
+
|
398
|
+
|
185
399
|
return true
|
186
400
|
|
401
|
+
|
402
|
+
|
187
|
-
}
|
403
|
+
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
404
|
+
|
192
|
-
|
193
|
-
|
405
|
+
|
194
|
-
|
195
|
-
|
406
|
+
|
196
|
-
|
197
|
-
|
407
|
+
|
198
|
-
|
199
|
-
|
408
|
+
|
200
|
-
|
201
|
-
|
409
|
+
|
202
|
-
|
203
|
-
alert1(title: "",message: "")
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
}
|
208
410
|
|
209
411
|
}
|
210
412
|
|
211
|
-
|
212
|
-
|
213
413
|
```
|
25
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -156,8 +156,6 @@
|
|
156
156
|
|
157
157
|
})
|
158
158
|
|
159
|
-
print("aaaa")
|
160
|
-
|
161
159
|
}
|
162
160
|
|
163
161
|
|
@@ -213,9 +211,3 @@
|
|
213
211
|
|
214
212
|
|
215
213
|
```
|
216
|
-
|
217
|
-
Filenameが上手く取得出来ません。
|
218
|
-
|
219
|
-
Buttonの所のif文もFilenameと比べたいのですが
|
220
|
-
|
221
|
-
うまくいきません
|
24
test
CHANGED
File without changes
|
test
CHANGED
@@ -214,16 +214,8 @@
|
|
214
214
|
|
215
215
|
```
|
216
216
|
|
217
|
-
一応、これで画面遷移はできましたが、これだと、"1.png"という文字と比べているだけだと思われます。
|
218
|
-
|
219
|
-
|
217
|
+
Filenameが上手く取得出来ません。
|
220
|
-
|
221
|
-
|
218
|
+
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
219
|
+
Buttonの所のif文もFilenameと比べたいのですが
|
226
|
-
|
220
|
+
|
227
|
-
|
221
|
+
うまくいきません
|
228
|
-
|
229
|
-
もしくはそれが出来ない場合、写真アプリをこちらで作り、比較するのか?もしくはDocumentsに画像データを保存した方がいいのか?
|
23
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -152,9 +152,7 @@
|
|
152
152
|
|
153
153
|
assets.enumerateObjects({ asset, _, _ in
|
154
154
|
|
155
|
-
let photo = PHAsset.fetchAssets(with: .image, pptions: nil).firstObject
|
156
|
-
|
157
|
-
let filename: String = asset.value(forKey: "filename")as! String
|
155
|
+
let filename: String = assets.value(forKey: "filename")as! String
|
158
156
|
|
159
157
|
})
|
160
158
|
|
22
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -152,7 +152,9 @@
|
|
152
152
|
|
153
153
|
assets.enumerateObjects({ asset, _, _ in
|
154
154
|
|
155
|
+
let photo = PHAsset.fetchAssets(with: .image, pptions: nil).firstObject
|
156
|
+
|
155
|
-
let
|
157
|
+
let filename: String = asset.value(forKey: "filename")as! String
|
156
158
|
|
157
159
|
})
|
158
160
|
|
21
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,21 +40,11 @@
|
|
40
40
|
|
41
41
|
import UIKit
|
42
42
|
|
43
|
-
|
44
|
-
|
45
43
|
import Photos
|
46
44
|
|
47
45
|
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
class ViewController: UIViewController,
|
47
|
+
class ViewController: UIViewController,UITextFieldDelegate{
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
48
|
|
59
49
|
|
60
50
|
|
@@ -62,82 +52,32 @@
|
|
62
52
|
|
63
53
|
|
64
54
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
let userDefaults = UserDefaults.standard
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
var tableView: UITableView!
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
55
|
func alert1(title:String,message:String){
|
86
56
|
|
87
|
-
|
88
|
-
|
89
57
|
alertController = UIAlertController(title: "データが存在しません", message: "", preferredStyle: UIAlertController.Style.alert)
|
90
58
|
|
91
|
-
|
92
|
-
|
93
59
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
94
60
|
|
95
|
-
|
96
|
-
|
97
61
|
present(alertController, animated: true)
|
98
62
|
|
99
|
-
|
100
|
-
|
101
|
-
}
|
63
|
+
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
64
|
|
107
65
|
|
108
66
|
|
109
67
|
func alert2(title:String,message:String){
|
110
68
|
|
111
|
-
|
112
|
-
|
113
69
|
alertController = UIAlertController(title: "データを入力してください", message: "", preferredStyle: UIAlertController.Style.alert)
|
114
70
|
|
115
|
-
|
116
|
-
|
117
71
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
118
72
|
|
119
|
-
|
120
|
-
|
121
73
|
present(alertController, animated: true)
|
122
74
|
|
123
|
-
|
124
|
-
|
125
|
-
}
|
75
|
+
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
76
|
|
135
77
|
|
136
78
|
|
137
79
|
override func viewDidLoad() {
|
138
80
|
|
139
|
-
|
140
|
-
|
141
81
|
super.viewDidLoad()
|
142
82
|
|
143
83
|
|
@@ -148,521 +88,125 @@
|
|
148
88
|
|
149
89
|
libraryRequestAuthorization()
|
150
90
|
|
151
|
-
|
152
|
-
|
153
|
-
getAllPhotosInfo()
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
TextFil
|
91
|
+
TextField.delegate = self
|
158
|
-
|
159
|
-
|
160
|
-
|
92
|
+
|
161
|
-
TextFil
|
93
|
+
TextField.layer.borderWidth = 1.5
|
94
|
+
|
162
|
-
|
95
|
+
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 8, height: 5))
|
96
|
+
|
163
|
-
|
97
|
+
TextField.leftView = paddingView
|
98
|
+
|
164
|
-
|
99
|
+
TextField.leftViewMode = .always
|
100
|
+
|
165
|
-
self.view.addSubview(TextFil
|
101
|
+
self.view.addSubview(TextField)
|
166
|
-
|
167
|
-
|
168
|
-
|
102
|
+
|
169
|
-
}
|
103
|
+
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
104
|
+
|
105
|
+
|
176
106
|
|
177
107
|
override func didReceiveMemoryWarning() {
|
178
108
|
|
179
|
-
|
180
|
-
|
181
109
|
super.didReceiveMemoryWarning()
|
182
110
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
case .notDetermined:
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
print("決まっていない")
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
case .restricted:
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
print("制限あり")
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
@unknown default:
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
return
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
})
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
fileprivate func getAllPhotosInfo(){//カメラロールから全てを取得
|
266
|
-
|
267
|
-
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
fileprivate func libraryRequestAuthorization() {
|
116
|
+
|
117
|
+
PHPhotoLibrary.requestAuthorization({status in
|
118
|
+
|
119
|
+
switch status {
|
120
|
+
|
121
|
+
case .authorized:
|
122
|
+
|
123
|
+
self.getAllPhotosInfo()
|
124
|
+
|
125
|
+
case .denied:
|
126
|
+
|
127
|
+
print("拒否されました")
|
128
|
+
|
129
|
+
case .notDetermined:
|
130
|
+
|
131
|
+
print("決まっていない")
|
132
|
+
|
133
|
+
case .restricted:
|
134
|
+
|
135
|
+
print("制限あり")
|
136
|
+
|
137
|
+
@unknown default:
|
138
|
+
|
139
|
+
return
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
})
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
fileprivate func getAllPhotosInfo(){
|
268
150
|
|
269
151
|
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
270
152
|
|
271
|
-
|
272
|
-
|
273
153
|
assets.enumerateObjects({ asset, _, _ in
|
274
154
|
|
275
|
-
let
|
155
|
+
let _: String = asset.value(forKey: "filename")as! String
|
276
|
-
|
277
|
-
|
278
156
|
|
279
157
|
})
|
280
158
|
|
281
|
-
|
282
|
-
|
283
159
|
print("aaaa")
|
284
160
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
fi
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
func addHistory(text: String){
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
if text == ""{
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
return
|
344
|
-
|
345
|
-
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
@IBOutlet weak var TextField: UITextField!
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
170
|
+
|
171
|
+
self.view.endEditing(true)
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
178
|
+
|
179
|
+
TextField.resignFirstResponder()
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
186
|
+
|
187
|
+
return true
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
@IBAction func Button(_ sender: UIButton) {
|
194
|
+
|
195
|
+
if (TextField.text == "filename" ){
|
196
|
+
|
197
|
+
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
198
|
+
|
199
|
+
} else if (TextField.text! == "" ){
|
200
|
+
|
201
|
+
alert2(title: "", message: "")
|
202
|
+
|
203
|
+
} else {
|
204
|
+
|
205
|
+
alert1(title: "",message: "")
|
346
206
|
|
347
207
|
}
|
348
208
|
|
349
|
-
|
350
|
-
|
351
|
-
var histories = getInputHistory()
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
for word in histories{
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
if word == text {
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
return
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
209
|
+
}
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
}
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
histories.insert(text, at: 0)
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
userDefaults.set(histories, forKey: "InputHistory")
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
}
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
func removeHistory(index : Int){
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
var histories = getInputHistory()
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
histories.remove(at: index)
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
userDefaults.set(histories, forKey: "inputHistory")
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
}
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
func getInputHistory() -> [String] {
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
if let histories = userDefaults.array(forKey: "inputHistory")as? [String]{
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
return histories
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
return []
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
}
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
@objc func inputFromHistory(sender: UITapGestureRecognizer){
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
if let cell = sender.view as? UITableViewCell{
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
TextFiled.text = cell.textLabel?.text
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
}
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
}
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
self.view.endEditing(true)
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
}
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
textField.resignFirstResponder()
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
tableView.removeFromSuperview()
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
addHistory(text: TextFiled.text!)
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
textField.text = ""
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
return true
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
}
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
return getInputHistory().count
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
}
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
let cell = UITableViewCell(style: .default, reuseIdentifier: "Cell")
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
cell.textLabel?.text = getInputHistory()[indexPath.row]
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
cell.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.inputFromHistory(sender:))))
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
return cell
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
}
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
return "削除"
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
}
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
private func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: NSIndexPath) {
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
removeHistory(index: indexPath.row)
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
tableView.deleteRows(at: [indexPath as IndexPath], with: .fade)
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
}
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
return true
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
}
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
return true
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
}
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
@IBAction func Button(_ sender: UIButton) {
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
if (TextFiled.text == "filename"){
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
} else if (TextFiled.text! == "" ){
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
alert2(title: "", message: "")
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
} else {
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
alert1(title: "",message: "")
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
}
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
}
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
210
|
|
667
211
|
}
|
668
212
|
|
20
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -272,13 +272,7 @@
|
|
272
272
|
|
273
273
|
assets.enumerateObjects({ asset, _, _ in
|
274
274
|
|
275
|
-
|
275
|
+
let filename: String = assets.value(forKey: "filename")as! String
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
276
|
|
283
277
|
|
284
278
|
|
19
文の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,27 +40,69 @@
|
|
40
40
|
|
41
41
|
import UIKit
|
42
42
|
|
43
|
+
|
44
|
+
|
43
45
|
import Photos
|
44
46
|
|
45
47
|
|
46
48
|
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
47
|
-
class ViewController: UIViewController, UITextFieldDelegate{
|
53
|
+
class ViewController: UIViewController, UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource {
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
48
60
|
|
49
61
|
var alertController: UIAlertController!
|
50
62
|
|
51
63
|
|
52
64
|
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
let userDefaults = UserDefaults.standard
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
var tableView: UITableView!
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
53
85
|
func alert1(title:String,message:String){
|
54
86
|
|
55
87
|
|
56
88
|
|
57
|
-
alertController = UIAlertController(title: "データが存在しません", message: "", preferredStyle: UIAlertController.Style.alert)
|
89
|
+
alertController = UIAlertController(title: "データが存在しません", message: "", preferredStyle: UIAlertController.Style.alert)
|
58
|
-
|
90
|
+
|
91
|
+
|
92
|
+
|
59
|
-
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
93
|
+
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
60
|
-
|
94
|
+
|
95
|
+
|
96
|
+
|
61
|
-
present(alertController, animated: true)
|
97
|
+
present(alertController, animated: true)
|
62
|
-
|
98
|
+
|
99
|
+
|
100
|
+
|
63
|
-
}
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
64
106
|
|
65
107
|
|
66
108
|
|
@@ -68,153 +110,565 @@
|
|
68
110
|
|
69
111
|
|
70
112
|
|
71
|
-
alertController = UIAlertController(title: "データを入力してください", message: "", preferredStyle: UIAlertController.Style.alert)
|
113
|
+
alertController = UIAlertController(title: "データを入力してください", message: "", preferredStyle: UIAlertController.Style.alert)
|
72
|
-
|
114
|
+
|
115
|
+
|
116
|
+
|
73
|
-
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
117
|
+
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
74
|
-
|
118
|
+
|
119
|
+
|
120
|
+
|
75
|
-
present(alertController, animated: true)
|
121
|
+
present(alertController, animated: true)
|
76
|
-
|
122
|
+
|
123
|
+
|
124
|
+
|
77
|
-
}
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
78
134
|
|
79
135
|
|
80
136
|
|
81
137
|
override func viewDidLoad() {
|
82
138
|
|
139
|
+
|
140
|
+
|
83
141
|
super.viewDidLoad()
|
84
142
|
|
143
|
+
|
144
|
+
|
85
145
|
// Do any additional setup after loading the view.
|
86
146
|
|
147
|
+
|
148
|
+
|
87
149
|
libraryRequestAuthorization()
|
88
150
|
|
151
|
+
|
152
|
+
|
153
|
+
getAllPhotosInfo()
|
154
|
+
|
155
|
+
|
156
|
+
|
89
157
|
TextFiled.delegate = self
|
90
158
|
|
159
|
+
|
160
|
+
|
91
161
|
TextFiled.layer.borderWidth = 1.5
|
92
162
|
|
163
|
+
|
164
|
+
|
165
|
+
self.view.addSubview(TextFiled)
|
166
|
+
|
167
|
+
|
168
|
+
|
93
|
-
}
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
94
174
|
|
95
175
|
|
96
176
|
|
97
177
|
override func didReceiveMemoryWarning() {
|
98
178
|
|
179
|
+
|
180
|
+
|
99
181
|
super.didReceiveMemoryWarning()
|
100
182
|
|
183
|
+
|
184
|
+
|
101
|
-
}
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
102
190
|
|
103
191
|
|
104
192
|
|
105
193
|
fileprivate func libraryRequestAuthorization() { //カメラロールへのアクセスの許可
|
106
194
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
195
|
+
|
196
|
+
|
197
|
+
PHPhotoLibrary.requestAuthorization({status in
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
switch status {
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
case .authorized:
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
self.getAllPhotosInfo()
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
case .denied:
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
print("拒否されました")
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
case .notDetermined:
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
print("決まっていない")
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
case .restricted:
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
print("制限あり")
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
@unknown default:
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
return
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
})
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
fileprivate func getAllPhotosInfo(){//カメラロールから全てを取得
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
assets.enumerateObjects({ asset, _, _ in
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
})
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
print("aaaa")
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
fileprivate func transitionToSettingsApplition() {
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
let url = URL(string: UIApplication.openSettingsURLString)
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
if let url = url {
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
@IBOutlet weak var TextFiled: UITextField!
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
func addHistory(text: String){
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
if text == ""{
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
return
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
var histories = getInputHistory()
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
for word in histories{
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
if word == text {
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
return
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
|
130
376
|
|
131
377
|
}
|
132
378
|
|
133
|
-
|
379
|
+
|
134
|
-
|
135
|
-
|
380
|
+
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
fileprivate func getAllPhotosInfo(){ //カメラロールから全てを取得
|
140
|
-
|
141
|
-
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
142
|
-
|
143
|
-
assets.enumerateObjects({ asset, _, _ in
|
144
|
-
|
145
|
-
})
|
146
|
-
|
147
|
-
|
381
|
+
histories.insert(text, at: 0)
|
148
|
-
|
382
|
+
|
383
|
+
|
384
|
+
|
149
|
-
|
385
|
+
userDefaults.set(histories, forKey: "InputHistory")
|
150
|
-
|
151
|
-
|
386
|
+
|
152
|
-
|
153
|
-
|
387
|
+
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
fileprivate func transitionToSettingsApplition() {
|
158
|
-
|
159
|
-
let url = URL(string: UIApplication.openSettingsURLString)
|
160
|
-
|
161
|
-
if let url = url {
|
162
|
-
|
163
|
-
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
164
|
-
|
165
|
-
}
|
166
388
|
|
167
389
|
}
|
168
390
|
|
169
391
|
|
170
392
|
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
func removeHistory(index : Int){
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
var histories = getInputHistory()
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
histories.remove(at: index)
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
userDefaults.set(histories, forKey: "inputHistory")
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
func getInputHistory() -> [String] {
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
if let histories = userDefaults.array(forKey: "inputHistory")as? [String]{
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
return histories
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
}
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
return []
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
}
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
@objc func inputFromHistory(sender: UITapGestureRecognizer){
|
450
|
+
|
451
|
+
|
452
|
+
|
171
|
-
|
453
|
+
if let cell = sender.view as? UITableViewCell{
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
TextFiled.text = cell.textLabel?.text
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
}
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
172
470
|
|
173
471
|
|
174
472
|
|
175
473
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
176
474
|
|
475
|
+
|
476
|
+
|
177
477
|
self.view.endEditing(true)
|
178
478
|
|
479
|
+
|
480
|
+
|
179
|
-
}
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
180
486
|
|
181
487
|
|
182
488
|
|
183
489
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
184
490
|
|
491
|
+
|
492
|
+
|
185
493
|
textField.resignFirstResponder()
|
186
494
|
|
495
|
+
|
496
|
+
|
497
|
+
tableView.removeFromSuperview()
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
addHistory(text: TextFiled.text!)
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
textField.text = ""
|
506
|
+
|
507
|
+
|
508
|
+
|
187
509
|
return true
|
188
510
|
|
511
|
+
|
512
|
+
|
189
|
-
}
|
513
|
+
}
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
return getInputHistory().count
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
let cell = UITableViewCell(style: .default, reuseIdentifier: "Cell")
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
cell.textLabel?.text = getInputHistory()[indexPath.row]
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
cell.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.inputFromHistory(sender:))))
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
return cell
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
return "削除"
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
}
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
private func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: NSIndexPath) {
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
removeHistory(index: indexPath.row)
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
tableView.deleteRows(at: [indexPath as IndexPath], with: .fade)
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
return true
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
}
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
190
614
|
|
191
615
|
|
192
616
|
|
193
617
|
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
194
618
|
|
619
|
+
|
620
|
+
|
195
621
|
return true
|
196
622
|
|
623
|
+
|
624
|
+
|
197
|
-
}
|
625
|
+
}
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
|
198
630
|
|
199
631
|
|
200
632
|
|
201
633
|
@IBAction func Button(_ sender: UIButton) {
|
202
634
|
|
635
|
+
|
636
|
+
|
203
|
-
if (TextFiled.text == ""){
|
637
|
+
if (TextFiled.text == "filename"){
|
204
|
-
|
638
|
+
|
639
|
+
|
640
|
+
|
205
|
-
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
641
|
+
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
206
|
-
|
642
|
+
|
643
|
+
|
644
|
+
|
207
|
-
} else if (TextFiled.text! == "" ){
|
645
|
+
} else if (TextFiled.text! == "" ){
|
208
|
-
|
646
|
+
|
647
|
+
|
648
|
+
|
209
|
-
alert2(title: "", message: "")
|
649
|
+
alert2(title: "", message: "")
|
210
|
-
|
650
|
+
|
651
|
+
|
652
|
+
|
211
|
-
} else {
|
653
|
+
} else {
|
212
|
-
|
654
|
+
|
655
|
+
|
656
|
+
|
213
|
-
alert1(title: "",message: "")
|
657
|
+
alert1(title: "",message: "")
|
214
|
-
|
658
|
+
|
659
|
+
|
660
|
+
|
215
|
-
}
|
661
|
+
}
|
216
|
-
|
662
|
+
|
663
|
+
|
664
|
+
|
217
|
-
}
|
665
|
+
}
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
|
218
672
|
|
219
673
|
}
|
220
674
|
|
18
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -142,10 +142,14 @@
|
|
142
142
|
|
143
143
|
assets.enumerateObjects({ asset, _, _ in
|
144
144
|
|
145
|
-
let filename: String = asset .value(forkey: "filename") as! String
|
146
|
-
|
147
145
|
})
|
148
146
|
|
147
|
+
if let firsrAsset = {
|
148
|
+
|
149
|
+
let filename: String = firstasset .value(forKey: "filename") as! String
|
150
|
+
|
151
|
+
}
|
152
|
+
|
149
153
|
}
|
150
154
|
|
151
155
|
|
@@ -196,7 +200,7 @@
|
|
196
200
|
|
197
201
|
@IBAction func Button(_ sender: UIButton) {
|
198
202
|
|
199
|
-
if (TextFiled.text == "
|
203
|
+
if (TextFiled.text == ""){
|
200
204
|
|
201
205
|
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
202
206
|
|
17
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,61 +40,27 @@
|
|
40
40
|
|
41
41
|
import UIKit
|
42
42
|
|
43
|
-
|
44
|
-
|
45
43
|
import Photos
|
46
44
|
|
47
45
|
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
class ViewController: UIViewController, UITextFieldDelegate
|
47
|
+
class ViewController: UIViewController, UITextFieldDelegate{
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
var photoAssets: Array! = [PHAsset]() //PHAssetのリスト変数
|
62
|
-
|
63
|
-
|
64
48
|
|
65
49
|
var alertController: UIAlertController!
|
66
50
|
|
67
51
|
|
68
52
|
|
69
|
-
var imageNameStr: String = "1.png"
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
53
|
func alert1(title:String,message:String){
|
78
54
|
|
79
55
|
|
80
56
|
|
81
57
|
alertController = UIAlertController(title: "データが存在しません", message: "", preferredStyle: UIAlertController.Style.alert)
|
82
58
|
|
83
|
-
|
84
|
-
|
85
59
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
86
60
|
|
87
|
-
|
88
|
-
|
89
61
|
present(alertController, animated: true)
|
90
62
|
|
91
|
-
|
92
|
-
|
93
|
-
}
|
63
|
+
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
64
|
|
99
65
|
|
100
66
|
|
@@ -104,410 +70,152 @@
|
|
104
70
|
|
105
71
|
alertController = UIAlertController(title: "データを入力してください", message: "", preferredStyle: UIAlertController.Style.alert)
|
106
72
|
|
107
|
-
|
108
|
-
|
109
73
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
110
74
|
|
111
|
-
|
112
|
-
|
113
75
|
present(alertController, animated: true)
|
114
76
|
|
115
|
-
|
116
|
-
|
117
|
-
}
|
77
|
+
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
78
|
|
131
79
|
|
132
80
|
|
133
81
|
override func viewDidLoad() {
|
134
82
|
|
135
|
-
|
136
|
-
|
137
83
|
super.viewDidLoad()
|
138
84
|
|
139
|
-
|
140
|
-
|
141
85
|
// Do any additional setup after loading the view.
|
142
86
|
|
143
|
-
|
144
|
-
|
145
87
|
libraryRequestAuthorization()
|
146
88
|
|
147
|
-
|
148
|
-
|
149
89
|
TextFiled.delegate = self
|
150
90
|
|
151
|
-
|
152
|
-
|
153
91
|
TextFiled.layer.borderWidth = 1.5
|
154
92
|
|
155
|
-
|
156
|
-
|
157
|
-
}
|
93
|
+
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
94
|
|
163
95
|
|
164
96
|
|
165
97
|
override func didReceiveMemoryWarning() {
|
166
98
|
|
167
|
-
|
168
|
-
|
169
99
|
super.didReceiveMemoryWarning()
|
170
100
|
|
171
|
-
|
172
|
-
|
173
|
-
}
|
101
|
+
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
102
|
|
179
103
|
|
180
104
|
|
181
105
|
fileprivate func libraryRequestAuthorization() { //カメラロールへのアクセスの許可
|
182
106
|
|
183
|
-
|
184
|
-
|
185
|
-
PHPhotoLibrary.requestAuthorization({
|
107
|
+
PHPhotoLibrary.requestAuthorization({status in
|
108
|
+
|
186
|
-
|
109
|
+
switch status {
|
110
|
+
|
187
|
-
|
111
|
+
case .authorized:
|
112
|
+
|
188
|
-
|
113
|
+
print("承認済み")
|
114
|
+
|
189
|
-
|
115
|
+
case .denied:
|
116
|
+
|
190
|
-
|
117
|
+
print("拒否されました")
|
118
|
+
|
191
|
-
|
119
|
+
case .notDetermined:
|
120
|
+
|
121
|
+
print("決まっていない")
|
122
|
+
|
123
|
+
case .restricted:
|
124
|
+
|
125
|
+
print("制限あり")
|
126
|
+
|
127
|
+
@unknown default:
|
192
128
|
|
193
129
|
return
|
194
130
|
|
195
|
-
|
196
|
-
|
197
131
|
}
|
198
132
|
|
199
|
-
|
133
|
+
})
|
134
|
+
|
200
|
-
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
fileprivate func getAllPhotosInfo(){ //カメラロールから全てを取得
|
140
|
+
|
141
|
+
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
142
|
+
|
143
|
+
assets.enumerateObjects({ asset, _, _ in
|
144
|
+
|
145
|
+
let filename: String = asset .value(forkey: "filename") as! String
|
146
|
+
|
147
|
+
})
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
fileprivate func transitionToSettingsApplition() {
|
154
|
+
|
155
|
+
let url = URL(string: UIApplication.openSettingsURLString)
|
156
|
+
|
201
|
-
|
157
|
+
if let url = url {
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
158
|
+
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
print("承認済み")
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
case .denied:
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
print("拒否されました")
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
case
|
159
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
print("決まっていない")
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
case .restricted:
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
print("制限あり")
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
@unknown default:
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
return
|
242
|
-
|
243
|
-
|
244
160
|
|
245
161
|
}
|
246
162
|
|
247
|
-
|
248
|
-
|
249
|
-
})
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
fileprivate func getAllPhotosInfo(){ //カメラロールから全てを取得
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
assets.enumerateObjects({ [weak self] (asset, index, stop) -> Void in
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
guard self != nil else{
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
return
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
}
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
self?.photoAssets.append(asset as PHAsset)
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
})
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
}
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
fileprivate func showDeniedAlert() {
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
let alert: UIAlertController = UIAlertController(title: "エラー",
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
message: "「写真」へのアクセスが拒否されています。設定より変更してください。",
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
preferredStyle: .alert)
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
let cancel: UIAlertAction = UIAlertAction(title: "キャンセル",
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
style: .cancel,
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
handler: nil)
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
let ok: UIAlertAction = UIAlertAction(title: "設定画面へ",
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
style: .default,
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
handler: { [weak self] (action) -> Void in
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
guard self != nil else {
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
return
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
self?.transitionToSettingsApplition()
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
})
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
alert.addAction(cancel)
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
alert.addAction(ok)
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
present(alert, animated: true, completion: nil)
|
370
|
-
|
371
|
-
|
372
|
-
|
373
163
|
}
|
374
164
|
|
375
165
|
|
376
166
|
|
377
|
-
|
167
|
+
@IBOutlet weak var TextFiled: UITextField!
|
378
|
-
|
379
|
-
|
380
|
-
|
168
|
+
|
169
|
+
|
170
|
+
|
381
|
-
|
171
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
172
|
+
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
173
|
+
self.view.endEditing(true)
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
174
|
+
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
398
|
-
|
179
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
180
|
+
|
399
|
-
|
181
|
+
textField.resignFirstResponder()
|
182
|
+
|
183
|
+
return true
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
190
|
+
|
191
|
+
return true
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
@IBAction func Button(_ sender: UIButton) {
|
198
|
+
|
199
|
+
if (TextFiled.text == "filename"){
|
200
|
+
|
201
|
+
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
202
|
+
|
203
|
+
} else if (TextFiled.text! == "" ){
|
204
|
+
|
205
|
+
alert2(title: "", message: "")
|
206
|
+
|
207
|
+
} else {
|
208
|
+
|
209
|
+
alert1(title: "",message: "")
|
400
210
|
|
401
211
|
}
|
402
212
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
@IBOutlet weak var TextFiled: UITextField!
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
self.view.endEditing(true)
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
}
|
213
|
+
}
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
textField.resignFirstResponder()
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
return true
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
}
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
return true
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
}
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
@IBAction func Button(_ sender: UIButton) {
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
if (imageNameStr != "" && TextFiled.text! == imageNameStr){
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
} else if (TextFiled.text! == "" ){
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
alert2(title: "", message: "")
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
} else {
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
alert1(title: "",message: "")
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
}
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
}
|
498
|
-
|
499
|
-
|
500
214
|
|
501
215
|
}
|
502
216
|
|
503
217
|
|
504
218
|
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
219
|
```
|
512
220
|
|
513
221
|
一応、これで画面遷移はできましたが、これだと、"1.png"という文字と比べているだけだと思われます。
|
16
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
-
var imageNameStr: String = "
|
69
|
+
var imageNameStr: String = "1.png"
|
70
70
|
|
71
71
|
|
72
72
|
|
15
文の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,31 +42,467 @@
|
|
42
42
|
|
43
43
|
|
44
44
|
|
45
|
+
import Photos
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
45
53
|
class ViewController: UIViewController, UITextFieldDelegate {
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
var
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
var photoAssets: Array! = [PHAsset]() //PHAssetのリスト変数
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
var alertController: UIAlertController!
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
var imageNameStr: String = "Kosaten1"
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
func alert1(title:String,message:String){
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
alertController = UIAlertController(title: "データが存在しません", message: "", preferredStyle: UIAlertController.Style.alert)
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
present(alertController, animated: true)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
func alert2(title:String,message:String){
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
alertController = UIAlertController(title: "データを入力してください", message: "", preferredStyle: UIAlertController.Style.alert)
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
present(alertController, animated: true)
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
override func viewDidLoad() {
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
super.viewDidLoad()
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
// Do any additional setup after loading the view.
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
libraryRequestAuthorization()
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
TextFiled.delegate = self
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
TextFiled.layer.borderWidth = 1.5
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
override func didReceiveMemoryWarning() {
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
super.didReceiveMemoryWarning()
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
fileprivate func libraryRequestAuthorization() { //カメラロールへのアクセスの許可
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
PHPhotoLibrary.requestAuthorization({[weak self] status in
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
guard self != nil else{
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
return
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
switch status {
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
case .authorized:
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
print("承認済み")
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
case .denied:
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
print("拒否されました")
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
case .notDetermined:
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
print("決まっていない")
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
case .restricted:
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
print("制限あり")
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
@unknown default:
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
return
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
})
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
fileprivate func getAllPhotosInfo(){ //カメラロールから全てを取得
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
assets.enumerateObjects({ [weak self] (asset, index, stop) -> Void in
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
guard self != nil else{
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
return
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
self?.photoAssets.append(asset as PHAsset)
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
})
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
fileprivate func showDeniedAlert() {
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
let alert: UIAlertController = UIAlertController(title: "エラー",
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
message: "「写真」へのアクセスが拒否されています。設定より変更してください。",
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
preferredStyle: .alert)
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
let cancel: UIAlertAction = UIAlertAction(title: "キャンセル",
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
style: .cancel,
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
handler: nil)
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
let ok: UIAlertAction = UIAlertAction(title: "設定画面へ",
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
style: .default,
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
handler: { [weak self] (action) -> Void in
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
guard self != nil else {
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
return
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
self?.transitionToSettingsApplition()
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
})
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
alert.addAction(cancel)
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
alert.addAction(ok)
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
present(alert, animated: true, completion: nil)
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
fileprivate func transitionToSettingsApplition() {
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
let url = URL(string: UIApplication.openSettingsURLString)
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
if let url = url {
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
@IBOutlet weak var TextFiled: UITextField!
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
self.view.endEditing(true)
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
}
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
textField.resignFirstResponder()
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
return true
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
return true
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
@IBAction func Button(_ sender: UIButton) {
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
if (imageNameStr != "" && TextFiled.text! == imageNameStr){
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
} else if (TextFiled.text! == "" ){
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
alert2(title: "", message: "")
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
} else {
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
alert1(title: "",message: "")
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
|
66
500
|
|
67
501
|
}
|
68
502
|
|
69
|
-
|
503
|
+
|
504
|
+
|
505
|
+
|
70
506
|
|
71
507
|
|
72
508
|
|
14
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
画面遷移 ボタン1つ(画像データと文字)
|
1
|
+
至急案件 画面遷移 ボタン1つ(画像データと文字)
|
test
CHANGED
File without changes
|
13
test
CHANGED
File without changes
|
test
CHANGED
@@ -84,6 +84,6 @@
|
|
84
84
|
|
85
85
|
写真アプリの中の画像データと比較したいのです。
|
86
86
|
|
87
|
-
なので imageNameStrの所をどうしたら写真アプリの中にある画像データになるのか
|
87
|
+
なので imageNameStrの所をどうしたら写真アプリの中にある画像データになるのか。
|
88
88
|
|
89
|
-
|
89
|
+
もしくはそれが出来ない場合、写真アプリをこちらで作り、比較するのか?もしくはDocumentsに画像データを保存した方がいいのか?
|
12
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
至急案件です。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
1
|
写真アプリに1.pngという画像データを保存しておき、文字を入力、入力した文字と、画像データのデータ名が** 同じ時** に画面遷移することは可能でしょうか?
|
6
2
|
|
7
3
|
|
11
test
CHANGED
File without changes
|
test
CHANGED
@@ -87,3 +87,7 @@
|
|
87
87
|
|
88
88
|
|
89
89
|
写真アプリの中の画像データと比較したいのです。
|
90
|
+
|
91
|
+
なので imageNameStrの所をどうしたら写真アプリの中にある画像データになるのか
|
92
|
+
|
93
|
+
教えてください!
|
10
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
画面遷移 ボタン1つ
|
1
|
+
画面遷移 ボタン1つ(画像データと文字)
|
test
CHANGED
File without changes
|
9
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,4 +86,4 @@
|
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
写真アプリの画像データと比較したいのです。
|
89
|
+
写真アプリの中の画像データと比較したいのです。
|
8
文の削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,10 +35,6 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
コードとして このように書きましたがどうですか?
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
また、データは存在しません。というprint文の表記をlabelに表示するにはどのようにすればよろしいでしょうか?
|
42
38
|
|
43
39
|
|
44
40
|
|
7
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,14 +35,6 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
コードとして このように書きましたがどうですか?
|
38
|
-
|
39
|
-
また、また画面遷移先は現状8つあるので、1.png~8.pngがあるのですが
|
40
|
-
|
41
|
-
1つ1つimageNamestrに書いていくのか
|
42
|
-
|
43
|
-
else分の所で、何かできるのか
|
44
|
-
|
45
|
-
教えてください。
|
46
38
|
|
47
39
|
|
48
40
|
|
6
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
写真アプリ 1.png 2.png というデータ名で保存しておく。
|
9
|
+
写真アプリ 1.png 2.png というデータ名で画像データを保存しておく。
|
10
10
|
|
11
11
|
|
12
12
|
|
@@ -30,11 +30,7 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
**この時の写真アプリは iPhoneにもともとある”写真”というアプリです。**
|
33
|
+
**この時のデータを保存している写真アプリは iPhoneにもともとある”写真”というアプリです。**
|
34
|
-
|
35
|
-
または、Documentsを作り、その中に画像データを入れておく方がスムーズに動くのか教えていただけますか?そもそもあらかじめ画像データをDocumetsの中に入れることはできるのか?
|
36
|
-
|
37
|
-
|
38
34
|
|
39
35
|
|
40
36
|
|
@@ -62,150 +58,44 @@
|
|
62
58
|
|
63
59
|
|
64
60
|
|
61
|
+
class ViewController: UIViewController, UITextFieldDelegate {
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
@IBOutlet weak var TextField: UITetxtField!
|
65
66
|
|
66
67
|
|
67
68
|
|
69
|
+
var imageNameStr: String = "1.png"
|
68
70
|
|
71
|
+
|
72
|
+
|
73
|
+
@IBAction func Button(_ sender: UIButton) {
|
74
|
+
|
75
|
+
if (imageNameStr != "" && TextField.text! == imageNameStr) {
|
76
|
+
|
69
|
-
|
77
|
+
self.performSegue(withIdentifier: "ViewController2", sender: nil)
|
78
|
+
|
79
|
+
} else {
|
80
|
+
|
81
|
+
print("画像データが存在しません")
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
70
86
|
|
71
87
|
|
72
88
|
|
73
89
|
|
74
90
|
|
91
|
+
```
|
75
92
|
|
93
|
+
一応、これで画面遷移はできましたが、これだと、"1.png"という文字と比べているだけだと思われます。
|
76
94
|
|
95
|
+
写真アプリににある画像データとの比較ではないと思われます
|
96
|
+
|
77
|
-
|
97
|
+
ためしに、画像データを全部削除してやってみましたが、画像がなくても画面遷移したので。
|
78
98
|
|
79
99
|
|
80
100
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
var imageNameStr: String = "1.png"
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
@IBAction func Button(_ sender: UIButton){
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if (imageNameStr != "1.png" && TextField.text! == imageNameStr) {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
let storyboard = self.storyboard!
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
let nextView = storyboard.instantiateViewController(withIdentifier: "ViewController1")
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
self.present(nextView, animated: true, completion: nil)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
} else {
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
101
|
+
写真アプリの画像データと比較したいのです。
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
override func viewDidLoad() {
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
super.viewDidLoad()
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
// Do any additional setup after loading the view.
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
TextField.delegate = self
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
}
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
override func didReceiveMemoryWarning() {
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
super.didReceiveMemoryWarning()
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
self.view.endEditing(true)
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
textField.resignFirstResponder()
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
return true
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
```
|
5
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
**この時の写真アプリは iPhoneにもともとある”写真”というアプリです。**
|
34
34
|
|
35
|
-
または、Documentsを作り、その中に画像データを入れておく方がスムーズに動くのか教えていただけますか?
|
35
|
+
または、Documentsを作り、その中に画像データを入れておく方がスムーズに動くのか教えていただけますか?そもそもあらかじめ画像データをDocumetsの中に入れることはできるのか?
|
36
36
|
|
37
37
|
|
38
38
|
|
4
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
至急案件です。
|
2
2
|
|
3
3
|
|
4
4
|
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
支給案件です。
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
写真アプリに1.pngという画像データを保存しておき、文字を入力、入力した文字と、画像データのデータ名が** 同じ時** に画面遷移することは可能でしょうか?
|
2
6
|
|
3
7
|
|
@@ -28,6 +32,8 @@
|
|
28
32
|
|
29
33
|
**この時の写真アプリは iPhoneにもともとある”写真”というアプリです。**
|
30
34
|
|
35
|
+
または、Documentsを作り、その中に画像データを入れておく方がスムーズに動くのか教えていただけますか?
|
36
|
+
|
31
37
|
|
32
38
|
|
33
39
|
|
@@ -44,13 +50,7 @@
|
|
44
50
|
|
45
51
|
|
46
52
|
|
47
|
-
また、データは存在しません。という表記をlabelに表示するにはどのようにすればよろしいでしょうか?
|
53
|
+
また、データは存在しません。というprint文の表記をlabelに表示するにはどのようにすればよろしいでしょうか?
|
48
|
-
|
49
|
-
また、入力した文字を検索履歴として、TextViewにて表示したいのですが、labelの値渡しのやり方はいくつか乗っていたのですが、TextViewではどのようにするのでしょうか?
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
至急案件です!
|
54
54
|
|
55
55
|
|
56
56
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,6 +48,12 @@
|
|
48
48
|
|
49
49
|
また、入力した文字を検索履歴として、TextViewにて表示したいのですが、labelの値渡しのやり方はいくつか乗っていたのですが、TextViewではどのようにするのでしょうか?
|
50
50
|
|
51
|
+
|
52
|
+
|
53
|
+
至急案件です!
|
54
|
+
|
55
|
+
|
56
|
+
|
51
57
|
```Swiift
|
52
58
|
|
53
59
|
|
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,13 @@
|
|
40
40
|
|
41
41
|
else分の所で、何かできるのか
|
42
42
|
|
43
|
-
教えてください
|
43
|
+
教えてください。
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
また、データは存在しません。という表記をlabelに表示するにはどのようにすればよろしいでしょうか?
|
48
|
+
|
49
|
+
また、入力した文字を検索履歴として、TextViewにて表示したいのですが、labelの値渡しのやり方はいくつか乗っていたのですが、TextViewではどのようにするのでしょうか?
|
44
50
|
|
45
51
|
```Swiift
|
46
52
|
|