Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pause & countdown på frågor

  • Loading branch information...
commit c5dce9588ec7747f2d853e2e144f37db87d6ce9a 1 parent a87a4d2
@jonasdahl jonasdahl authored
View
4 Projektarbete/Projektarbete_v1_2/MathExerciseViewController.m
@@ -792,10 +792,6 @@ -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)
if ([self.navigationController.viewControllers objectAtIndex:1] != nil) {
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
}
- else {
- [self performSegueWithIdentifier:@"exerciseToMain" sender:self];
- }
-
} else if (buttonIndex == 1) {
//Restarta
questionAtm = 0;
View
47 Projektarbete/Projektarbete_v1_2/MathTableCellController.xib
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1536</int>
- <string key="IBDocument.SystemVersion">12C54</string>
- <string key="IBDocument.InterfaceBuilderVersion">2840</string>
+ <string key="IBDocument.SystemVersion">12C60</string>
+ <string key="IBDocument.InterfaceBuilderVersion">2843</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">1926</string>
+ <string key="NS.object.0">1929</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
@@ -45,6 +45,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{54, 15}, {173, 29}}</string>
<reference key="NSSuperview" ref="281890344"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="394225447"/>
<string key="NSReuseIdentifierKey">_NS:323</string>
<bool key="IBUIOpaque">NO</bool>
@@ -78,6 +79,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{124, 19}, {123, 21}}</string>
<reference key="NSSuperview" ref="281890344"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="705786699"/>
<string key="NSReuseIdentifierKey">_NS:323</string>
<bool key="IBUIOpaque">NO</bool>
@@ -111,6 +113,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{15, 11}, {31, 31}}</string>
<reference key="NSSuperview" ref="281890344"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="11732183"/>
<string key="NSReuseIdentifierKey">_NS:567</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
@@ -121,6 +124,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{255, 15}, {25, 25}}</string>
<reference key="NSSuperview" ref="281890344"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="575985751"/>
<string key="NSReuseIdentifierKey">_NS:567</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
@@ -135,6 +139,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{15, 52}, {265, 1}}</string>
<reference key="NSSuperview" ref="281890344"/>
+ <reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
@@ -172,6 +177,7 @@
</array>
<string key="NSFrameSize">{320, 53}</string>
<reference key="NSSuperview" ref="80510322"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="692317561"/>
<string key="NSReuseIdentifierKey">_NS:395</string>
<object class="NSColor" key="IBUIBackgroundColor" id="934709305">
@@ -187,6 +193,7 @@
</array>
<string key="NSFrameSize">{320, 54}</string>
<reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="281890344"/>
<string key="NSReuseIdentifierKey">_NS:384</string>
<reference key="IBUIBackgroundColor" ref="934709305"/>
@@ -299,7 +306,37 @@
<nil key="sourceID"/>
<int key="maxID">27</int>
</object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <object class="IBPartialClassDescription">
+ <string key="className">MathTableCellController</string>
+ <string key="superclassName">UITableViewCell</string>
+ <dictionary class="NSMutableDictionary" key="outlets">
+ <string key="imageView">UIImageView</string>
+ <string key="titleLabel">UILabel</string>
+ <string key="valueLabel">UILabel</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <object class="IBToOneOutletInfo" key="imageView">
+ <string key="name">imageView</string>
+ <string key="candidateClassName">UIImageView</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="titleLabel">
+ <string key="name">titleLabel</string>
+ <string key="candidateClassName">UILabel</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="valueLabel">
+ <string key="name">valueLabel</string>
+ <string key="candidateClassName">UILabel</string>
+ </object>
+ </dictionary>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/MathTableCellController.h</string>
+ </object>
+ </object>
+ </array>
+ </object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
@@ -312,6 +349,6 @@
<string key="NS.key.0">Arrow1.png</string>
<string key="NS.object.0">{38, 33}</string>
</object>
- <string key="IBCocoaTouchPluginVersion">1926</string>
+ <string key="IBCocoaTouchPluginVersion">1929</string>
</data>
</archive>
View
9 Projektarbete/Projektarbete_v1_2/NatureDetailViewController.h
@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
-@interface NatureDetailViewController : UIViewController {
+@interface NatureDetailViewController : UIViewController <UIActionSheetDelegate> {
int categoryID;
NSString *subject;
}
@@ -19,9 +19,16 @@
@property (weak, nonatomic) IBOutlet UIButton *buttonTwo;
@property (weak, nonatomic) IBOutlet UIButton *buttonThree;
@property (weak, nonatomic) IBOutlet UIButton *buttonFour;
+@property (weak, nonatomic) IBOutlet UIView *darkView;
+@property (weak, nonatomic) IBOutlet UILabel *countdownLabel;
+@property (nonatomic, retain) NSTimer *startCountdownTimer;
+@property (nonatomic, retain) NSDate *startCountdownDate;
+- (IBAction)pauseButtonPressed:(id)sender;
+@property (nonatomic) float startCountdown;
@property (nonatomic) int categoryID;
@property (nonatomic, retain) NSString *subject;
@property (nonatomic, retain) NSMutableArray *category;
- (IBAction)backButton:(id)sender;
+@property (weak, nonatomic) IBOutlet UIButton *pauseButton;
@end
View
55 Projektarbete/Projektarbete_v1_2/NatureDetailViewController.m
@@ -14,7 +14,7 @@ @interface NatureDetailViewController ()
@implementation NatureDetailViewController
-@synthesize categoryID, subject, category, subjectLabel, questionLabel, buttonOne, buttonTwo, buttonThree, buttonFour;
+@synthesize categoryID, subject, category, subjectLabel, questionLabel, buttonOne, buttonTwo, buttonThree, buttonFour, startCountdownTimer, countdownLabel, darkView, startCountdownDate, startCountdown;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
@@ -27,6 +27,14 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- (void)viewDidLoad
{
+ [darkView setHidden:NO];
+ startCountdownDate = [NSDate date];
+ startCountdownTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f/10.0f
+ target:self
+ selector:@selector(startCountdownMethod)
+ userInfo:nil
+ repeats:YES];
+
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
category = [[NSMutableArray alloc] init];
@@ -105,6 +113,29 @@ - (NSInteger)tableView:(UITableView *)tableView
return 0;
}
+- (void)startCountdownMethod
+{
+ [self setStartCountdown:3-fabs([startCountdownDate timeIntervalSinceNow])];
+ NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:startCountdown];
+
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setDateFormat:@"s"];
+ [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
+ NSString *timeString=[dateFormatter stringFromDate:timerDate];
+
+ int val = [timeString intValue]+1;
+
+ countdownLabel.text = [NSString stringWithFormat:@"%i", val];
+ if (startCountdown <= 0) {
+ [darkView setHidden:YES];
+ //[darkView removeFromSuperview];
+ [startCountdownTimer invalidate];
+ startCountdownTimer = nil;
+ //[self nextButtonPressed];
+ }
+
+}
+
- (void)viewDidUnload {
[self setSubjectLabel:nil];
@@ -113,9 +144,31 @@ - (void)viewDidUnload {
[self setButtonTwo:nil];
[self setButtonThree:nil];
[self setButtonFour:nil];
+ [self setDarkView:nil];
+ [self setCountdownLabel:nil];
+ [self setPauseButton:nil];
[super viewDidUnload];
}
- (IBAction)backButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
+- (IBAction)pauseButtonPressed:(id)sender {
+ UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Quiz paused" delegate:self cancelButtonTitle:@"Resume" destructiveButtonTitle:@"Exit" otherButtonTitles:@"Restart quiz", nil];
+ popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
+ [popupQuery showInView:[UIApplication sharedApplication].keyWindow];
+}
+-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
+
+ if (buttonIndex == 0) {
+ if ([self.navigationController.viewControllers objectAtIndex:1] != nil) {
+ [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
+ }
+
+ } else if (buttonIndex == 1) {
+ [self viewDidLoad];
+
+ } else if (buttonIndex == 2) {
+
+ }
+}
@end
View
57 Projektarbete/Projektarbete_v1_2/en.lproj/MainStoryboard.storyboard
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2840" systemVersion="12C54" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="3">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2843" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="3">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1926"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1929"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
@@ -1512,21 +1512,6 @@
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
- <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="c10-AO-qXo">
- <rect key="frame" x="0.0" y="-6" width="72" height="62"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
- <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
- <state key="normal" title="Back" image="bakåtpil.png">
- <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
- <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
- </state>
- <state key="highlighted">
- <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
- </state>
- <connections>
- <action selector="backButton:" destination="aTp-rB-Gfw" eventType="touchUpInside" id="KeE-it-eFA"/>
- </connections>
- </button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Question" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="skC-2l-h2g">
<rect key="frame" x="0.0" y="101" width="320" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -1582,6 +1567,37 @@
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="L8n-Hw-9hf">
+ <rect key="frame" x="242" y="10" width="66" height="31"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+ <state key="normal" title="Pause">
+ <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <state key="highlighted">
+ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <connections>
+ <action selector="pauseButtonPressed:" destination="aTp-rB-Gfw" eventType="touchUpInside" id="jT7-IN-5Gh"/>
+ </connections>
+ </button>
+ <view contentMode="scaleToFill" id="C44-HC-SVK">
+ <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <subviews>
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="3" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="2v9-K7-ZK2">
+ <rect key="frame" x="49" y="139" width="222" height="202"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" name="GillSans-Bold" family="Gill Sans" pointSize="150"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ <color key="shadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+ <size key="shadowOffset" width="-1" height="-1"/>
+ </label>
+ </subviews>
+ <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="calibratedRGB"/>
+ </view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
@@ -1592,6 +1608,9 @@
<outlet property="buttonOne" destination="9Xm-R1-WUT" id="NsI-lH-GDn"/>
<outlet property="buttonThree" destination="oYk-fe-POV" id="Xsu-wK-25G"/>
<outlet property="buttonTwo" destination="sjr-Pi-ab1" id="q2Y-P0-uPo"/>
+ <outlet property="countdownLabel" destination="2v9-K7-ZK2" id="cQr-F6-c9x"/>
+ <outlet property="darkView" destination="C44-HC-SVK" id="6vk-Be-UIp"/>
+ <outlet property="pauseButton" destination="L8n-Hw-9hf" id="PaI-qY-vWW"/>
<outlet property="questionLabel" destination="skC-2l-h2g" id="R4P-KG-KGH"/>
<outlet property="subjectLabel" destination="LV7-ko-8yR" id="sAI-vq-Qax"/>
</connections>
@@ -1767,10 +1786,14 @@
<source key="sourceIdentifier" type="project" relativePath="./Classes/NatureDetailViewController.h"/>
<relationships>
<relationship kind="action" name="backButton:"/>
+ <relationship kind="action" name="pauseButtonPressed:"/>
<relationship kind="outlet" name="buttonFour" candidateClass="UIButton"/>
<relationship kind="outlet" name="buttonOne" candidateClass="UIButton"/>
<relationship kind="outlet" name="buttonThree" candidateClass="UIButton"/>
<relationship kind="outlet" name="buttonTwo" candidateClass="UIButton"/>
+ <relationship kind="outlet" name="countdownLabel" candidateClass="UILabel"/>
+ <relationship kind="outlet" name="darkView" candidateClass="UIView"/>
+ <relationship kind="outlet" name="pauseButton" candidateClass="UIButton"/>
<relationship kind="outlet" name="questionLabel" candidateClass="UILabel"/>
<relationship kind="outlet" name="subjectLabel" candidateClass="UILabel"/>
</relationships>
Please sign in to comment.
Something went wrong with that request. Please try again.