-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/settings #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
24434d6
設定画面への遷移でエラー
NMai-source 70038e5
設定画面への遷移でエラー
29c65c8
設定画面への遷移でエラー
NMai-source 84b21f8
設定画面を追加
NMai-source d2e5674
設定画面を追加
NMai-source b8fa425
設定画面を追加
NMai-source 950f532
ファイルの削除
NMai-source eb37a58
ライブラリの更新は元に戻す
ykws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
現状はモーダル表示になっているため、ナビゲーションコントローラを利用して、ナビゲーション遷移としてください。
以下の記事を参考にしてみてください。
NavigationControllerをStoryboardで追加する