Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions OneTimePasswordExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
08C8E27826BBA377006D4608 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 08C8E27726BBA377006D4608 /* Assets.xcassets */; };
08C8E27B26BBA377006D4608 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08C8E27926BBA377006D4608 /* LaunchScreen.storyboard */; };
08C8E27E26BBA377006D4608 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08C8E27D26BBA377006D4608 /* main.m */; };
4F8B41252703520D00CF6A1A /* SettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F8B41242703520D00CF6A1A /* SettingController.m */; };
4F8B41292705F8CF00CF6A1A /* SettingsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F8B41282705F8CF00CF6A1A /* SettingsTableViewCell.m */; };
4F8B412D2709A50E00CF6A1A /* SettingTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4F8B412C2709A50E00CF6A1A /* SettingTableViewCell.xib */; };
9A376FD397E03D93D3D80530 /* libPods-OneTimePasswordExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C08B5529218DAFE111F19B53 /* libPods-OneTimePasswordExample.a */; };
/* End PBXBuildFile section */

Expand All @@ -30,6 +33,11 @@
08C8E27A26BBA377006D4608 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
08C8E27C26BBA377006D4608 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
08C8E27D26BBA377006D4608 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4F8B41242703520D00CF6A1A /* SettingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingController.m; sourceTree = "<group>"; };
4F8B4126270484D900CF6A1A /* SettingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingController.h; sourceTree = "<group>"; };
4F8B41272705F8A900CF6A1A /* SettingsTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsTableViewCell.h; sourceTree = "<group>"; };
4F8B41282705F8CF00CF6A1A /* SettingsTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingsTableViewCell.m; sourceTree = "<group>"; };
4F8B412C2709A50E00CF6A1A /* SettingTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingTableViewCell.xib; sourceTree = "<group>"; };
62EA47A9FA5474BBDDECC144 /* Pods-OneTimePasswordExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneTimePasswordExample.debug.xcconfig"; path = "Target Support Files/Pods-OneTimePasswordExample/Pods-OneTimePasswordExample.debug.xcconfig"; sourceTree = "<group>"; };
C08B5529218DAFE111F19B53 /* libPods-OneTimePasswordExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneTimePasswordExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
C0CF9A46AE07C0F1865C69D3 /* Pods-OneTimePasswordExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneTimePasswordExample.release.xcconfig"; path = "Target Support Files/Pods-OneTimePasswordExample/Pods-OneTimePasswordExample.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -68,13 +76,18 @@
08C8E26A26BBA376006D4608 /* OneTimePasswordExample */ = {
isa = PBXGroup;
children = (
4F8B41272705F8A900CF6A1A /* SettingsTableViewCell.h */,
4F8B41282705F8CF00CF6A1A /* SettingsTableViewCell.m */,
08C8E26B26BBA376006D4608 /* AppDelegate.h */,
08C8E26C26BBA376006D4608 /* AppDelegate.m */,
08C8E26E26BBA376006D4608 /* SceneDelegate.h */,
08C8E26F26BBA376006D4608 /* SceneDelegate.m */,
08C8E27126BBA376006D4608 /* ViewController.h */,
08C8E27226BBA376006D4608 /* ViewController.m */,
4F8B41242703520D00CF6A1A /* SettingController.m */,
4F8B4126270484D900CF6A1A /* SettingController.h */,
08C8E27426BBA376006D4608 /* Main.storyboard */,
4F8B412C2709A50E00CF6A1A /* SettingTableViewCell.xib */,
08C8E27726BBA377006D4608 /* Assets.xcassets */,
08C8E27926BBA377006D4608 /* LaunchScreen.storyboard */,
08C8E27C26BBA377006D4608 /* Info.plist */,
Expand Down Expand Up @@ -159,6 +172,7 @@
files = (
08C8E27B26BBA377006D4608 /* LaunchScreen.storyboard in Resources */,
08C8E27826BBA377006D4608 /* Assets.xcassets in Resources */,
4F8B412D2709A50E00CF6A1A /* SettingTableViewCell.xib in Resources */,
08C8E27626BBA376006D4608 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -197,6 +211,8 @@
files = (
08C8E27326BBA376006D4608 /* ViewController.m in Sources */,
08C8E26D26BBA376006D4608 /* AppDelegate.m in Sources */,
4F8B41292705F8CF00CF6A1A /* SettingsTableViewCell.m in Sources */,
4F8B41252703520D00CF6A1A /* SettingController.m in Sources */,
08C8E27E26BBA377006D4608 /* main.m in Sources */,
08C8E27026BBA376006D4608 /* SceneDelegate.m in Sources */,
);
Expand Down
67 changes: 64 additions & 3 deletions OneTimePasswordExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19150" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19134"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -29,16 +30,27 @@
<constraint firstAttribute="width" secondItem="aqW-F6-Yvt" secondAttribute="height" multiplier="1:1" id="MXv-9b-Vrh"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YFg-3N-DhZ">
<rect key="frame" x="10" y="701.5" width="394" height="31"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="設定"/>
<connections>
<segue destination="maI-u2-Zio" kind="show" identifier="to setting" id="iaU-Pc-RNd"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="aqW-F6-Yvt" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="AeY-GP-fD2"/>
<constraint firstItem="aqW-F6-Yvt" firstAttribute="width" secondItem="6Tk-OE-BBY" secondAttribute="width" multiplier="0.5" id="AmS-rV-sYa"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="YFg-3N-DhZ" secondAttribute="trailing" constant="10" id="CKU-d1-VyH"/>
<constraint firstItem="JX5-NB-jZf" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="20" id="GpX-Ui-bjc"/>
<constraint firstItem="YFg-3N-DhZ" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="10" id="M75-BF-OI1"/>
<constraint firstItem="aqW-F6-Yvt" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="P0k-om-EuG"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="JX5-NB-jZf" secondAttribute="trailing" constant="20" id="m6S-1i-viQ"/>
<constraint firstItem="aqW-F6-Yvt" firstAttribute="top" secondItem="JX5-NB-jZf" secondAttribute="bottom" constant="40" id="ng0-Pg-es5"/>
<constraint firstItem="YFg-3N-DhZ" firstAttribute="top" secondItem="aqW-F6-Yvt" secondAttribute="bottom" constant="150" id="s5y-KA-9sU"/>
</constraints>
</view>
<connections>
Expand All @@ -48,7 +60,56 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="20" y="79"/>
<point key="canvasLocation" x="18.840579710144929" y="78.348214285714278"/>
</scene>
<!--Setting Controller-->
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next-badge

現状はモーダル表示になっているため、ナビゲーションコントローラを利用して、ナビゲーション遷移としてください。

以下の記事を参考にしてみてください。

NavigationControllerをStoryboardで追加する

<scene sceneID="KmQ-w1-cif">
<objects>
<viewController id="maI-u2-Zio" customClass="SettingController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="DgX-Op-7fC">
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingsTableViewCell" id="6DC-et-efa" customClass="SettingsTableViewCell">
<rect key="frame" x="0.0" y="44.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="6DC-et-efa" id="DIh-8j-qZB">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dkI-vG-V8f">
<rect key="frame" x="29" y="11" width="33" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eJZ-98-6zi">
<rect key="frame" x="352" y="10" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="titleLabel" destination="dkI-vG-V8f" id="la4-97-ykA"/>
<outlet property="valueLabel" destination="eJZ-98-6zi" id="dP9-Ho-cFp"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="maI-u2-Zio" id="04E-Ah-z3H"/>
<outlet property="delegate" destination="maI-u2-Zio" id="O1g-UV-F2h"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="gZv-0X-QNQ"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="fZU-ge-jmc" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-197.10144927536234" y="-595.3125"/>
</scene>
</scenes>
<resources>
Expand Down
16 changes: 16 additions & 0 deletions OneTimePasswordExample/SettingController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SettingController.h
// OneTimePasswordExample
//
// Created by Mai Nakagami on 2021/09/29.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface SettingController : UITableViewController

@end

NS_ASSUME_NONNULL_END
140 changes: 140 additions & 0 deletions OneTimePasswordExample/SettingController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
//
// SettingController.m
// OneTimePasswordExample
//
// Created by Mai Nakagami on 2021/09/28.
//

#import "SettingController.h"
#import "SettingsTableViewCell.h"

#pragma mark - Settings item

typedef NS_ENUM(UInt8, SettingsItem) {
SettingsItem1,
SettingsItem2,
SettingsItme3,
};

extern SettingsItem SettingsItemUnknown;


#pragma mark - Settings table view controller

@interface SettingController () <UIPickerViewDataSource, UIPickerViewDelegate>

@property (nonatomic) SettingsItem settingsItem;

@property (nonatomic) UIPickerView *pickerView;

@property (nonatomic) NSArray *test1Patterns;
@property (nonatomic) NSArray *test2Patterns;
@property (nonatomic) NSArray *test3Patterns;

@property (nonatomic) NSString *test1;
@property (nonatomic) NSString *test2;
@property (nonatomic) NSString *test3;

@end

@implementation SettingController

- (void)viewDidLoad {
[super viewDidLoad];

self.pickerView = [[UIPickerView alloc] init];
self.pickerView.center = self.view.center;
self.pickerView.dataSource = self;
self.pickerView.delegate = self;
[self.view addSubview: self.pickerView];

self.test1Patterns = @[@"1", @"2", @"3"];
self.test2Patterns = @[@"4", @"5", @"6"];
self.test3Patterns = @[@"7", @"8", @"9"];

self.test1 = self.test1Patterns[0];
self.test2 = self.test2Patterns[0];
self.test3 = self.test3Patterns[0];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SettingsTableViewCell *cell = (SettingsTableViewCell *)[tableView dequeueReusableCellWithIdentifier: @"SettingsTableViewCell" forIndexPath:indexPath];

switch (indexPath.row) {
case 0:
cell.titleLabel.text = @"TEST1";
cell.valueLabel.text = self.test1;
break;
case 1:
cell.titleLabel.text = @"TEST2";
cell.valueLabel.text = self.test2;
break;
case 2:
cell.titleLabel.text = @"TEST3";
cell.valueLabel.text = self.test3;
break;
}

return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.pickerView selectRow:0 inComponent:0 animated:true];
[self.pickerView reloadAllComponents];
self.settingsItem = indexPath.row;
}

#pragma mark - Picker view data source

- (NSInteger)numberOfComponentsInPickerView:(nonnull UIPickerView *)pickerView {
return 1;
}

- (NSInteger)pickerView:(nonnull UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 3;
}

#pragma mark - Picker view delegate

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
switch (self.settingsItem) {
case SettingsItem1:
return self.test1Patterns[row];
case SettingsItem2:
return self.test2Patterns[row];
case SettingsItme3:
return self.test3Patterns[row];
}

return @"";
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
switch (self.settingsItem) {
case SettingsItem1:
self.test1 = self.test1Patterns[row];
break;
case SettingsItem2:
self.test2 = self.test2Patterns[row];
break;
case SettingsItme3:
self.test3 = self.test3Patterns[row];
break;
}

[self.tableView reloadData];
}

@end
Loading