forked from iimgal/StudyiOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification2ViewController.m
More file actions
88 lines (70 loc) · 2.14 KB
/
Copy pathNotification2ViewController.m
File metadata and controls
88 lines (70 loc) · 2.14 KB
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
//
// Notification2ViewController.m
// StudyiOS
//
// Created by on 11-10-27.
// Copyright (c) 2011年 ZhangYiCheng. All rights reserved.
//
#import "Notification2ViewController.h"
#import "NotificationViewController.h"
#import "Single.h"
@interface Notification2ViewController()
@property (copy, nonatomic) NSString *notiString;
@end
@implementation Notification2ViewController
@synthesize superDelegate;
@synthesize textView;
@synthesize string;
@synthesize notiString;
extern NSString *globalString;
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
if ([self.string isEqualToString:@"global"])
{
self.textView.text = [NSString stringWithFormat:@"%@:\n%@", self.string, globalString];
}
else if ([self.string isEqualToString:@"single"])
{
Single *single = [Single shareSingle];
self.textView.text = [NSString stringWithFormat:@"%@:\n%@", self.string, single.string];
}
else if ([self.string isEqualToString:@"delegate"])
{
self.textView.text = [NSString stringWithFormat:@"%@:\n%@", self.string, [self.superDelegate textView].text];
}
else if ([self.string isEqualToString:@"notification"])
{
}
[super viewDidLoad];
}
- (void)viewDidUnload
{
self.string = nil;
self.notiString = nil;
[self setTextView:nil];
[super viewDidUnload];
}
// 返回上个页面
- (IBAction)back:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
if ([self.string isEqualToString:@"notification"]) {
NSDictionary *dic = [NSDictionary dictionaryWithObject:self.textView.text forKey:@"text"];
// 发送一个通知
// 第一个参数表示发出的通知的名称
// 第二个参数表示谁发出的通知
// 第三个参数表示通知所带的信息
[[NSNotificationCenter defaultCenter] postNotificationName:@"test1" object:self userInfo:dic];
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.textView resignFirstResponder];
}
@end