diff --git a/PopupViewTest/PopupViewTestViewController.h b/PopupViewTest/PopupViewTestViewController.h
index 0b5067e..43333be 100644
--- a/PopupViewTest/PopupViewTestViewController.h
+++ b/PopupViewTest/PopupViewTestViewController.h
@@ -38,5 +38,7 @@
int currentMessageIndex;
}
+- (IBAction)pushButton:(id)sender;
+
@end
diff --git a/PopupViewTest/PopupViewTestViewController.m b/PopupViewTest/PopupViewTestViewController.m
index e685ede..7c69a32 100644
--- a/PopupViewTest/PopupViewTestViewController.m
+++ b/PopupViewTest/PopupViewTestViewController.m
@@ -34,24 +34,29 @@
@implementation PopupViewTestViewController
-- (void)viewWillAppear:(BOOL)animated {
- messages = [NSArray arrayWithObjects:
- @"hoge",
- @"hoge",
- @"hoge",
- @"hoge",
- @"abcdaaaaaaaaaefghij",
- @"abcdaaaaaaaaaefghij",
- @"abcdaaaaaaaaaefghij",
- @"abcdaaaaaaaaaefghij",
- @"pict",
- @"pict",
- @"pict",
- @"pict",
- nil];
- [messages retain];
+- (IBAction)pushButton:(id)sender {
+ DNSLogMethod
- currentMessageIndex = 0;
+ if (popup == nil) {
+ if (currentMessageIndex == 0) {
+ popup = [[SNPopupView alloc] initWithImage:[UIImage imageNamed:@"2tchSmall.png"]];
+ currentMessageIndex = 1;
+ }
+ else {
+ popup = [[SNPopupView alloc] initWithString:@"test message" withFontOfSize:12];
+ currentMessageIndex = 0;
+ }
+ [popup showFromBarButtonItem:sender inView:self.view];
+ [popup addTarget:self action:@selector(didTouchPopupView:)];
+ [popup release];
+ }
+ else {
+ [popup dismiss];
+ popup = nil;
+ }
+}
+
+- (void)viewWillAppear:(BOOL)animated {
}
- (void)didTouchPopupView:(SNPopupView*)sender {
@@ -62,42 +67,22 @@ - (void)didTouchPopupView:(SNPopupView*)sender {
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
- NSString *nextTitle = [messages objectAtIndex:currentMessageIndex++];
-
- if (currentMessageIndex >= [messages count])
- currentMessageIndex = 0;
-
if (popup == nil) {
- if ([nextTitle isEqualToString:@"pict"])
+ if (currentMessageIndex == 0) {
popup = [[SNPopupView alloc] initWithImage:[UIImage imageNamed:@"2tchSmall.png"]];
- else
- popup = [[SNPopupView alloc] initWithString:nextTitle withFontOfSize:12];
+ currentMessageIndex = 1;
+ }
+ else {
+ popup = [[SNPopupView alloc] initWithString:@"test message" withFontOfSize:12];
+ currentMessageIndex = 0;
+ }
[popup showAtPoint:[touch locationInView:self.view] inView:self.view];
[popup addTarget:self action:@selector(didTouchPopupView:)];
[popup release];
}
else {
- NSString *currentTitle = popup.title;
-
- if ([currentTitle isEqualToString:nextTitle]) {
- [popup showAtPoint:[touch locationInView:self.view] inView:self.view];
- }
- else if (currentTitle == nil && [nextTitle isEqualToString:@"pict"]) {
- [popup showAtPoint:[touch locationInView:self.view] inView:self.view];
- }
- else {
- [popup dismiss];
- popup = nil;
-
- if ([nextTitle isEqualToString:@"pict"])
- popup = [[SNPopupView alloc] initWithImage:[UIImage imageNamed:@"2tchSmall.png"]];
- else
- popup = [[SNPopupView alloc] initWithString:nextTitle withFontOfSize:12];
-
- [popup showAtPoint:[touch locationInView:self.view] inView:self.view];
- [popup addTarget:self action:@selector(didTouchPopupView:)];
- [popup release];
- }
+ [popup dismiss];
+ popup = nil;
}
}
diff --git a/PopupViewTest/Resources/MainWindow.xib b/PopupViewTest/Resources/MainWindow.xib
index 71e587e..ad97288 100644
--- a/PopupViewTest/Resources/MainWindow.xib
+++ b/PopupViewTest/Resources/MainWindow.xib
@@ -51,7 +51,6 @@
292
{320, 480}
-
-