forked from chenyufeng1991/iOS-Oncenote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingViewController.m
103 lines (77 loc) · 2.99 KB
/
SettingViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// SettingViewController.m
// Oncenote
//
// Created by chenyufeng on 15/11/17.
// Copyright © 2015年 chenyufengweb. All rights reserved.
//
#import "SettingViewController.h"
#import "MainViewController.h"
#import "LoginViewController.h"
#import "AllUtils.h"
#import "SettingList.h"
#import "NicknameViewController.h"
@interface SettingViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *settingTableView;
@property(nonatomic,strong) SettingList *settingList;
@property(nonatomic,strong) NSArray *listArray;
@end
@implementation SettingViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.settingList = [[SettingList alloc] init];
self.listArray = self.settingList.settingListArray;
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [self.listArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SettingCell" forIndexPath:indexPath];
cell.textLabel.text = [self.listArray objectAtIndex:indexPath.row];
return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
case 0:{
[AllUtils jumpToViewController:@"NicknameViewController" contextViewController:self handler:nil];
}
break;
case 1:{
//修改密码;
[AllUtils jumpToViewController:@"UpdatePasswordViewController" contextViewController:self handler:nil];
}
break;
case 2:{
//从safari打开网页;
[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString:@"http://oncenote.bmob.cn/"]];
}
break;
case 3:{
[AllUtils jumpToViewController:@"AboutAppViewController" contextViewController:self handler:nil];
}
break;
default:
break;
}
}
#pragma mark - 所有按钮的点击操作
- (IBAction)naviCloseButtonPressed:(id)sender {
[AllUtils jumpToViewController:@"MainViewController" contextViewController:self handler:nil];
}
//退出登录按钮
- (IBAction)naviLogoutButtonPressed:(id)sender {
[AllUtils showPromptDialog:@"提示" andMessage:@"你真的要退出朝夕笔记吗?" OKButton:@"确定" OKButtonAction:^(UIAlertAction *action) {
//把用户名和密码设为nil;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:nil forKey:@"username"];
[userDefaults setObject:nil forKey:@"Password"];
[userDefaults setObject:nil forKey:@"nickname"];
[userDefaults setObject:nil forKey:@"userId"];
//同时跳转到登录界面;
[AllUtils jumpToViewController:@"LoginViewController" contextViewController:self handler:nil];
} cancelButton:@"取消" cancelButtonAction:^(UIAlertAction *action) {
} contextViewController:self];
}
@end