i have two view controller namely, "ViewController" and "ProcessingViewController". "ViewController" has two textfields and a button, while "ProcessingViewController" has a textfield.
when the button in "ViewController" is pressed, a segue will be triggered in "prepareForSegue" to start "ProcessingViewController". in "ProcessingViewController", some processing will be done and when finished I should go back to "ViewController".
the question is, how should I go back to ViewController from ProcesingViewController?
note:
I added a segue from ViewController to ProcessingViewController in the storyBoard, and I override prepareForeSegue method in ViewControoler
code:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"ProcessingViewController->before processing data: %@",
self.data);
self.data = @(self.data.integerValue * 10);
NSLog(@"ProcessingViewController->after processing data: %@",
self.data);
[_textFieldValueToBeProcessed setText:[self.data stringValue]];
[self.delegate processFinished:self.data];
//[self.navigationController popViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
}
storyboard:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EgF-YL-wkx">
<rect key="frame" x="123" y="386" width="129" height="90"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="send"/>
<connections>
<segue destination="Z1r-zV-tYu" kind="show" identifier="segueTransitToProcessingViewController" id="8OJ-jg-a4A"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="value to send" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="NGQ-pY-0eN">
<rect key="frame" x="48" y="202" width="279" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="value received" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="G88-eJ-Q35">
<rect key="frame" x="48" y="276" width="279" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="btnStartTransition" destination="EgF-YL-wkx" id="e07-ay-ZGi"/>
<outlet property="textFieldValueToBeProcessed" destination="NGQ-pY-0eN" id="RKE-Ag-AbW"/>
<outlet property="textFieldVlueAfterProcessing" destination="G88-eJ-Q35" id="Ih5-ih-I6p"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="116" y="123.68815592203899"/>
</scene>
<!--Processing View Controller-->
<scene sceneID="Txs-Cf-DUX">
<objects>
<viewController id="Z1r-zV-tYu" customClass="ProcessingViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="SNI-e8-8lZ"/>
<viewControllerLayoutGuide type="bottom" id="De6-we-dka"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="DME-Ab-bxq">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="received value after processing" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="bcF-KR-LLP">
<rect key="frame" x="50" y="318" width="238" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="textFieldValueToBeProcessed" destination="bcF-KR-LLP" id="fgE-IT-PWg"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="TXj-sv-7ZF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="860" y="123.68815592203899"/>
</scene>
</scenes>