码迷,mamicode.com
首页 > 其他好文 > 详细

多控制器管理练习 -- 私人通讯录

时间:2014-06-09 21:46:34      阅读:408      评论:0      收藏:0      [点我收藏+]

标签:des   c   style   class   blog   code   

Main.storyboard

bubuko.com,布布扣
bubuko.com,布布扣
  1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="bb1-yV-W1H">
  3     <dependencies>
  4         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
  5     </dependencies>
  6     <scenes>
  7         <!--Navigation Controller-->
  8         <scene sceneID="Fle-pH-X4o">
  9             <objects>
 10                 <navigationController definesPresentationContext="YES" id="bb1-yV-W1H" sceneMemberID="viewController">
 11                     <navigationBar key="navigationBar" contentMode="scaleToFill" id="Gxr-L7-62g">
 12                         <autoresizingMask key="autoresizingMask"/>
 13                     </navigationBar>
 14                     <connections>
 15                         <segue destination="xJJ-va-odp" kind="relationship" relationship="rootViewController" id="EcX-wk-iso"/>
 16                     </connections>
 17                 </navigationController>
 18                 <placeholder placeholderIdentifier="IBFirstResponder" id="cj9-h5-Qu2" userLabel="First Responder" sceneMemberID="firstResponder"/>
 19             </objects>
 20             <point key="canvasLocation" x="-558" y="306"/>
 21         </scene>
 22         <!--Login View Controller - 欢迎使用私人通讯录-->
 23         <scene sceneID="5uH-cq-Fn6">
 24             <objects>
 25                 <viewController id="xJJ-va-odp" customClass="LWTLoginViewController" sceneMemberID="viewController">
 26                     <layoutGuides>
 27                         <viewControllerLayoutGuide type="top" id="8zC-QD-qe8"/>
 28                         <viewControllerLayoutGuide type="bottom" id="mfz-9r-GPX"/>
 29                     </layoutGuides>
 30                     <view key="view" contentMode="scaleToFill" id="cER-fz-rEn">
 31                         <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
 32                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 33                         <subviews>
 34                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="账号" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MXY-Dd-ipt">
 35                                 <rect key="frame" x="20" y="94" width="34" height="21"/>
 36                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 37                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
 38                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
 39                                 <nil key="highlightedColor"/>
 40                             </label>
 41                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入账号(*)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="6GH-CK-uLQ">
 42                                 <rect key="frame" x="75" y="90" width="225" height="30"/>
 43                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 44                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
 45                                 <textInputTraits key="textInputTraits"/>
 46                             </textField>
 47                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="密码" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="d2H-q9-NMg">
 48                                 <rect key="frame" x="20" y="132" width="34" height="21"/>
 49                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 50                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
 51                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
 52                                 <nil key="highlightedColor"/>
 53                             </label>
 54                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入密码(*)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="VeK-0O-1rH">
 55                                 <rect key="frame" x="75" y="128" width="225" height="30"/>
 56                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 57                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
 58                                 <textInputTraits key="textInputTraits" secureTextEntry="YES"/>
 59                             </textField>
 60                             <view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KmK-PT-aNW">
 61                                 <rect key="frame" x="20" y="166" width="128" height="32"/>
 62                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 63                                 <subviews>
 64                                     <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="记住密码" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uXW-fL-WVe">
 65                                         <rect key="frame" x="0.0" y="6" width="58" height="22"/>
 66                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 67                                         <fontDescription key="fontDescription" type="system" pointSize="14"/>
 68                                         <nil key="highlightedColor"/>
 69                                     </label>
 70                                     <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="h9R-jw-hT5">
 71                                         <rect key="frame" x="79" y="1" width="51" height="31"/>
 72                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 73                                         <connections>
 74                                             <action selector="remPwdOnClick:" destination="xJJ-va-odp" eventType="valueChanged" id="939-Lr-mT4"/>
 75                                         </connections>
 76                                     </switch>
 77                                 </subviews>
 78                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
 79                             </view>
 80                             <view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FS6-U6-dS4">
 81                                 <rect key="frame" x="172" y="166" width="128" height="32"/>
 82                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 83                                 <subviews>
 84                                     <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="自动登录" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Cph-GJ-hQn">
 85                                         <rect key="frame" x="0.0" y="6" width="58" height="22"/>
 86                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 87                                         <fontDescription key="fontDescription" type="system" pointSize="14"/>
 88                                         <nil key="highlightedColor"/>
 89                                     </label>
 90                                     <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Fzg-fp-TOm">
 91                                         <rect key="frame" x="79" y="1" width="51" height="31"/>
 92                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 93                                         <connections>
 94                                             <action selector="autoLoginOnClick:" destination="xJJ-va-odp" eventType="valueChanged" id="YSj-wr-oF9"/>
 95                                         </connections>
 96                                     </switch>
 97                                 </subviews>
 98                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
 99                             </view>
100                             <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oTV-1X-kYO">
101                                 <rect key="frame" x="20" y="206" width="280" height="30"/>
102                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
103                                 <state key="normal" title="登录">
104                                     <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
105                                 </state>
106                                 <connections>
107                                     <action selector="loginBtnOnClick:" destination="xJJ-va-odp" eventType="touchUpInside" id="i1O-9W-6aq"/>
108                                 </connections>
109                             </button>
110                         </subviews>
111                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
112                     </view>
113                     <navigationItem key="navigationItem" title="欢迎使用私人通讯录" id="MPd-CY-FMs"/>
114                     <connections>
115                         <outlet property="LoginBtn" destination="oTV-1X-kYO" id="iFL-jN-T3o"/>
116                         <outlet property="accountField" destination="6GH-CK-uLQ" id="HCj-fY-mM5"/>
117                         <outlet property="autoLoginSwitch" destination="Fzg-fp-TOm" id="wXT-ea-waB"/>
118                         <outlet property="pwdField" destination="VeK-0O-1rH" id="wdi-bO-8Hw"/>
119                         <outlet property="remPwdSwitch" destination="h9R-jw-hT5" id="PIL-3p-pj2"/>
120                         <segue destination="yex-bI-OU8" kind="push" identifier="Login2Contact" id="0Gb-Uh-BD2"/>
121                     </connections>
122                 </viewController>
123                 <placeholder placeholderIdentifier="IBFirstResponder" id="JaW-jp-ZSY" userLabel="First Responder" sceneMemberID="firstResponder"/>
124             </objects>
125             <point key="canvasLocation" x="-141" y="306"/>
126         </scene>
127         <!--Contact Controller-->
128         <scene sceneID="wwf-DZ-MZT">
129             <objects>
130                 <tableViewController id="yex-bI-OU8" customClass="LWTContactController" sceneMemberID="viewController">
131                     <tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="OKw-pu-Z1g">
132                         <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
133                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
134                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
135                         <prototypes>
136                             <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="contacts" textLabel="Xfb-D6-ws9" detailTextLabel="T5o-wX-lg5" style="IBUITableViewCellStyleValue1" id="ZWc-Js-GHG" customClass="LWTContactCell">
137                                 <rect key="frame" x="0.0" y="86" width="320" height="44"/>
138                                 <autoresizingMask key="autoresizingMask"/>
139                                 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ZWc-Js-GHG" id="3RG-Ga-Gn4">
140                                     <rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
141                                     <autoresizingMask key="autoresizingMask"/>
142                                     <subviews>
143                                         <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Xfb-D6-ws9">
144                                             <rect key="frame" x="15" y="11" width="33" height="21"/>
145                                             <autoresizingMask key="autoresizingMask"/>
146                                             <fontDescription key="fontDescription" type="system" pointSize="17"/>
147                                             <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
148                                             <nil key="highlightedColor"/>
149                                         </label>
150                                         <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="T5o-wX-lg5">
151                                             <rect key="frame" x="241" y="11" width="44" height="21"/>
152                                             <autoresizingMask key="autoresizingMask"/>
153                                             <fontDescription key="fontDescription" type="system" pointSize="17"/>
154                                             <color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
155                                             <nil key="highlightedColor"/>
156                                         </label>
157                                     </subviews>
158                                 </tableViewCellContentView>
159                                 <connections>
160                                     <segue destination="LvV-eA-n6e" kind="push" id="hDj-Fr-IxZ"/>
161                                 </connections>
162                             </tableViewCell>
163                         </prototypes>
164                         <connections>
165                             <outlet property="dataSource" destination="yex-bI-OU8" id="Gix-qj-Lzk"/>
166                             <outlet property="delegate" destination="yex-bI-OU8" id="9fp-XG-7Yb"/>
167                         </connections>
168                     </tableView>
169                     <navigationItem key="navigationItem" id="dhn-fG-62U">
170                         <barButtonItem key="backBarButtonItem" title="返回" id="Sp3-IN-He2"/>
171                         <barButtonItem key="leftBarButtonItem" title="注销" id="BO2-tb-eyc">
172                             <connections>
173                                 <action selector="loginOutBtnOnClick:" destination="yex-bI-OU8" id="HaI-EY-TbG"/>
174                             </connections>
175                         </barButtonItem>
176                         <barButtonItem key="rightBarButtonItem" style="plain" systemItem="add" id="lfr-es-wMK">
177                             <connections>
178                                 <segue destination="Nua-d5-bto" kind="push" id="zU6-Am-7I0"/>
179                             </connections>
180                         </barButtonItem>
181                     </navigationItem>
182                 </tableViewController>
183                 <placeholder placeholderIdentifier="IBFirstResponder" id="tye-fg-0QE" userLabel="First Responder" sceneMemberID="firstResponder"/>
184             </objects>
185             <point key="canvasLocation" x="283" y="306"/>
186         </scene>
187         <!--Edit View Controller - 查看联系人-->
188         <scene sceneID="Fs8-48-OTY">
189             <objects>
190                 <viewController id="LvV-eA-n6e" customClass="LWTEditViewController" sceneMemberID="viewController">
191                     <layoutGuides>
192                         <viewControllerLayoutGuide type="top" id="H3D-Bq-Ki8"/>
193                         <viewControllerLayoutGuide type="bottom" id="MbN-DL-CL5"/>
194                     </layoutGuides>
195                     <view key="view" contentMode="scaleToFill" id="Wn2-Vv-nVA">
196                         <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
197                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
198                         <subviews>
199                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="姓名" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7aH-O7-WI9">
200                                 <rect key="frame" x="20" y="88" width="34" height="21"/>
201                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
202                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
203                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
204                                 <nil key="highlightedColor"/>
205                             </label>
206                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入姓名(*)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="kfW-LE-IXq">
207                                 <rect key="frame" x="75" y="84" width="225" height="30"/>
208                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
209                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
210                                 <textInputTraits key="textInputTraits"/>
211                             </textField>
212                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="电话" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="afp-hh-BYS">
213                                 <rect key="frame" x="20" y="126" width="34" height="21"/>
214                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
215                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
216                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
217                                 <nil key="highlightedColor"/>
218                             </label>
219                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入电话(*)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="K5Q-nW-F1w">
220                                 <rect key="frame" x="75" y="122" width="225" height="30"/>
221                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
222                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
223                                 <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
224                             </textField>
225                             <button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Htd-s7-WEM">
226                                 <rect key="frame" x="20" y="160" width="280" height="30"/>
227                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
228                                 <state key="normal" title="保存">
229                                     <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
230                                 </state>
231                                 <connections>
232                                     <action selector="addBtnOnClick:" destination="Nua-d5-bto" eventType="touchUpInside" id="uF9-jY-CFi"/>
233                                     <action selector="saveBtnOnClick:" destination="LvV-eA-n6e" eventType="touchUpInside" id="Lgd-F3-3xf"/>
234                                 </connections>
235                             </button>
236                         </subviews>
237                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
238                     </view>
239                     <navigationItem key="navigationItem" title="查看联系人" id="dIa-so-BIH">
240                         <barButtonItem key="rightBarButtonItem" title="编辑" id="cvr-Zf-Ai7">
241                             <connections>
242                                 <action selector="editBtnOnClick:" destination="LvV-eA-n6e" id="w99-PO-cVu"/>
243                             </connections>
244                         </barButtonItem>
245                     </navigationItem>
246                     <connections>
247                         <outlet property="nameField" destination="kfW-LE-IXq" id="rzU-8S-05S"/>
248                         <outlet property="phoneField" destination="K5Q-nW-F1w" id="sGp-tJ-cUx"/>
249                         <outlet property="saveBtn" destination="Htd-s7-WEM" id="Na9-FM-5gc"/>
250                     </connections>
251                 </viewController>
252                 <placeholder placeholderIdentifier="IBFirstResponder" id="ppP-zB-Rq3" userLabel="First Responder" sceneMemberID="firstResponder"/>
253             </objects>
254             <point key="canvasLocation" x="767" y="696"/>
255         </scene>
256         <!--Add View Controller - 添加联系人-->
257         <scene sceneID="2gI-cH-9qU">
258             <objects>
259                 <viewController id="Nua-d5-bto" customClass="LWTAddViewController" sceneMemberID="viewController">
260                     <layoutGuides>
261                         <viewControllerLayoutGuide type="top" id="TQR-wU-FwU"/>
262                         <viewControllerLayoutGuide type="bottom" id="EI6-0N-7Tn"/>
263                     </layoutGuides>
264                     <view key="view" contentMode="scaleToFill" id="vgB-NY-FXi">
265                         <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
266                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
267                         <subviews>
268                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="姓名" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EB4-3X-okK">
269                                 <rect key="frame" x="20" y="85" width="34" height="21"/>
270                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
271                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
272                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
273                                 <nil key="highlightedColor"/>
274                             </label>
275                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入姓名(*)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Yeq-UY-L2m">
276                                 <rect key="frame" x="75" y="81" width="225" height="30"/>
277                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
278                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
279                                 <textInputTraits key="textInputTraits"/>
280                             </textField>
281                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="电话" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nwf-hw-EOj">
282                                 <rect key="frame" x="20" y="123" width="34" height="21"/>
283                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
284                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
285                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
286                                 <nil key="highlightedColor"/>
287                             </label>
288                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入电话(*)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fH7-lR-Oxw">
289                                 <rect key="frame" x="75" y="119" width="225" height="30"/>
290                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
291                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
292                                 <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
293                             </textField>
294                             <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GCp-Vw-ry9">
295                                 <rect key="frame" x="20" y="157" width="280" height="30"/>
296                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
297                                 <state key="normal" title="添加">
298                                     <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
299                                 </state>
300                                 <connections>
301                                     <action selector="addBtnOnClick:" destination="Nua-d5-bto" eventType="touchUpInside" id="cfe-4i-VN1"/>
302                                 </connections>
303                             </button>
304                         </subviews>
305                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
306                     </view>
307                     <navigationItem key="navigationItem" title="添加联系人" id="gip-az-pqS"/>
308                     <connections>
309                         <outlet property="addBtn" destination="GCp-Vw-ry9" id="5oQ-zP-hB9"/>
310                         <outlet property="nameField" destination="Yeq-UY-L2m" id="eMA-zX-O2L"/>
311                         <outlet property="phoneField" destination="fH7-lR-Oxw" id="7tG-KJ-DCE"/>
312                     </connections>
313                 </viewController>
314                 <placeholder placeholderIdentifier="IBFirstResponder" id="9sC-Tm-Nzk" userLabel="First Responder" sceneMemberID="firstResponder"/>
315             </objects>
316             <point key="canvasLocation" x="767" y="-94"/>
317         </scene>
318     </scenes>
319     <simulatedMetricsContainer key="defaultSimulatedMetrics">
320         <simulatedStatusBarMetrics key="statusBar"/>
321         <simulatedOrientationMetrics key="orientation"/>
322         <simulatedScreenMetrics key="destination"/>
323     </simulatedMetricsContainer>
324 </document>
View Code
bubuko.com,布布扣

LWTLoginViewController.h

bubuko.com,布布扣
bubuko.com,布布扣
#import <UIKit/UIKit.h>

@interface LWTLoginViewController : UIViewController

@end
View Code
bubuko.com,布布扣

LWTLoginViewController.m

bubuko.com,布布扣
bubuko.com,布布扣
  1 //
  2 //  LWTLoginViewController.m
  3 //  多控制器管理联系 -- 私人通讯录
  4 //
  5 //  Created by apple on 14-6-7.
  6 //  Copyright (c) 2014年 lwt. All rights reserved.
  7 //
  8 
  9 #import "LWTLoginViewController.h"
 10 #import "MBProgressHUD+NJ.h"
 11 
 12 #define KLWTAccount @"account"
 13 #define KLWTPwd @"pwd"
 14 #define KLWTRemPwd @"remPwd"
 15 #define KLWTAutoLogin @"autoLogin"
 16 
 17 @interface LWTLoginViewController () <UITextFieldDelegate>
 18 /**
 19  *  账号输入框
 20  */
 21 @property (weak, nonatomic) IBOutlet UITextField *accountField;
 22 /**
 23  *  密码输入框
 24  */
 25 @property (weak, nonatomic) IBOutlet UITextField *pwdField;
 26 /**
 27  *  记住密码Switch
 28  */
 29 @property (weak, nonatomic) IBOutlet UISwitch *remPwdSwitch;
 30 /**
 31  *  自动登录Switch
 32  */
 33 @property (weak, nonatomic) IBOutlet UISwitch *autoLoginSwitch;
 34 /**
 35  *  登录按钮
 36  */
 37 @property (weak, nonatomic) IBOutlet UIButton *LoginBtn;
 38 /**
 39  *  监听点击记住密码
 40  */
 41 - (IBAction)remPwdOnClick:(UISwitch *)sender;
 42 /**
 43  *  监听点击自动登录
 44  */
 45 - (IBAction)autoLoginOnClick:(UISwitch *)sender;
 46 /**
 47  *  监听点击登录按钮
 48  */
 49 - (IBAction)loginBtnOnClick:(UIButton *)sender;
 50 
 51 @end
 52 
 53 @implementation LWTLoginViewController
 54 
 55 
 56 - (void)viewDidLoad
 57 {
 58     [super viewDidLoad];
 59     
 60     // 监听文本输入框的改变
 61     // 拿到通知中心
 62     NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
 63     // 注册监听
 64     [center addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.accountField];
 65     [center addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.pwdField];
 66     
 67     // 回显数据(读取保存的偏好设置信息)
 68     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 69     // 设置账号
 70     self.accountField.text = [defaults objectForKey:KLWTAccount];
 71     // 判断是否需要记住密码
 72     [self.remPwdSwitch setOn:[defaults boolForKey:KLWTRemPwd] animated:YES];
 73     if (self.remPwdSwitch.isOn) {
 74         // 设置密码
 75         self.pwdField.text = [defaults objectForKey:KLWTPwd];
 76         self.LoginBtn.enabled = YES;
 77     }
 78     [self.autoLoginSwitch setOn:[defaults boolForKey:KLWTAutoLogin] animated:YES];
 79     if (self.autoLoginSwitch.isOn) {
 80         // 自动登录
 81         [self loginBtnOnClick:nil];
 82     }
 83 }
 84 
 85 - (void)dealloc
 86 {
 87     [[NSNotificationCenter defaultCenter] removeObserver:self];
 88 }
 89 
 90 - (void)textChange
 91 {
 92     self.LoginBtn.enabled = (self.accountField.text.length >0 && self.pwdField.text.length > 0);
 93 }
 94 
 95 - (IBAction)remPwdOnClick:(UISwitch *)sender {
 96     // 判断是否记住密码
 97     if (self.remPwdSwitch.isOn == NO) {
 98         // 如果取消记住密码取消自动登录
 99         [self.autoLoginSwitch setOn:NO animated:YES];
100     }
101 }
102 
103 - (IBAction)autoLoginOnClick:(UISwitch *)sender {
104     // 判断是否自动登录
105     if (self.autoLoginSwitch.isOn) {
106         // 如果自动登录就记住密码
107         [self.remPwdSwitch setOn:YES animated:YES];
108     }
109 }
110 
111 - (IBAction)loginBtnOnClick:(UIButton *)sender {
112     // 添加蒙版禁止用户操作, 并且提示用户正在登录
113     [MBProgressHUD showMessage:@"登录中ing..."];
114     
115     
116     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
117         // 移除蒙版
118         [MBProgressHUD hideHUD];
119         
120         if ([self.accountField.text isEqualToString:@"lwt"] && [self.pwdField.text isEqualToString:@"123"]) {
121             // 登录成功后移除蒙版
122             [MBProgressHUD showSuccess:@"登录成功"];
123             
124             // 如果正确,跳转到联系人界面(手动执行segue)
125             [self performSegueWithIdentifier:@"Login2Contact" sender:nil];
126             
127             // 保存用户数据
128             NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
129             [defaults setObject:self.accountField.text forKey:KLWTAccount];
130             [defaults setObject:self.pwdField.text forKey:KLWTPwd];
131             [defaults setBool:self.remPwdSwitch.isOn forKey:KLWTRemPwd];
132             [defaults setBool:self.autoLoginSwitch.isOn forKey:KLWTAutoLogin];
133             
134             [defaults synchronize];
135             
136         }else
137         {
138             [MBProgressHUD showError:@"账号或密码错误"];
139         }
140     });
141 }
142 
143 // 在segue跳转之前调用, 会传入performSegueWithIdentifier方法创建好的segue对象
144 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
145 {
146     UIViewController *contact = segue.destinationViewController;
147     contact.title = [NSString stringWithFormat:@"%@ 的联系人列表", self.accountField.text];
148 
149 }
150 @end
View Code
bubuko.com,布布扣

LWTContactController.h

bubuko.com,布布扣
bubuko.com,布布扣
#import <UIKit/UIKit.h>

@interface LWTContactController : UITableViewController

@end
View Code
bubuko.com,布布扣

LWTContactController.m

bubuko.com,布布扣
bubuko.com,布布扣
  1 //
  2 //  LWTContactController.m
  3 //  多控制器管理联系 -- 私人通讯录
  4 //
  5 //  Created by apple on 14-6-7.
  6 //  Copyright (c) 2014年 lwt. All rights reserved.
  7 //
  8 
  9 #import "LWTContactController.h"
 10 #import "LWTContactCell.h"
 11 #import "LWTContactModel.h"
 12 #import "LWTAddViewController.h"
 13 #import "LWTEditViewController.h"
 14 
 15 #define KARCPath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"list.arc"]
 16 
 17 @interface LWTContactController () <UIActionSheetDelegate, LWTAddViewControllerDelegate, LWTEditViewControllerDelegate>
 18 /**
 19  *  点击注销登录
 20  */
 21 - (IBAction)loginOutBtnOnClick:(UIBarButtonItem *)sender;
 22 /**
 23  *  保存所有用户数据
 24  */
 25 @property (nonatomic, strong) NSMutableArray *contacts;
 26 
 27 @end
 28 
 29 @implementation LWTContactController
 30 
 31 #pragma mark - 懒加载
 32 - (NSMutableArray *)contacts
 33 {
 34     if (!_contacts) {
 35         // 从文件中读取数组
 36         _contacts =  [NSKeyedUnarchiver unarchiveObjectWithFile:KARCPath];
 37         // 如果第一次启动没有文件,就创建一个空的数组用于保存数据
 38         if (_contacts == nil) {
 39             _contacts = [NSMutableArray array];
 40         }
 41     }
 42     return _contacts;
 43 }
 44 
 45 
 46 - (void)viewDidLoad
 47 {
 48     [super viewDidLoad];
 49     
 50     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
 51 }
 52 
 53 // 无论是手动类型的segue还是自动类型的segue, 在跳转之前都会执行该方法
 54 // 控制器跳转之前(执行segue之前)执行
 55 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 56 {
 57     // 取出目标控制器
 58     UIViewController *vc = segue.destinationViewController;
 59     
 60     // 判断目标控制器是添加还是编辑
 61     if ([vc isKindOfClass:[LWTAddViewController class]]) {
 62         LWTAddViewController *addVC = (LWTAddViewController *)vc;
 63         // 设置代理
 64         addVC.delegate = self;
 65     }else if ([vc isKindOfClass:[LWTEditViewController class]])
 66     {
 67         LWTEditViewController *editVC = (LWTEditViewController *)vc;
 68         // 设置代理
 69         editVC.delegate = self;
 70         // 通过tableview获取被点击的行号
 71         NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
 72         // 赋值模型
 73         editVC.contact = self.contacts[indexPath.row];
 74     }
 75 
 76 }
 77 
 78 #pragma mark - 数据源方法
 79 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 80 {
 81     return self.contacts.count;
 82 }
 83 
 84 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 85 {
 86     // 创建cell
 87     LWTContactCell *cell = [LWTContactCell contactCellWithTableView:tableView];
 88     // 设置模型
 89     LWTContactModel *contact = self.contacts[indexPath.row];
 90     cell.contact = contact;
 91     //cell.textLabel.text = contact.name;
 92     //cell.detailTextLabel.text = contact.phone;
 93     // 返回cell
 94     return cell;
 95 }
 96 
 97 - (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
 98 {
 99      // 删除数据
100     [self.contacts removeObjectAtIndex:indexPath.row];
101     // 更新保存的数据
102     [NSKeyedArchiver archiveRootObject:self.contacts toFile:KARCPath];
103     
104     // 刷新表格
105     [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
106 }
107 
108 #pragma mark - LWTAddViewControllerDelegate
109 - (void)addViewControllerAddBtnClick:(LWTAddViewController *)addViewCOntroller andContact:(LWTContactModel *)contact
110 {
111     //
112     [self.contacts addObject:contact];
113     // 更新保存的数据
114     [NSKeyedArchiver archiveRootObject:self.contacts toFile:KARCPath];
115     
116     [self.tableView reloadData];
117     
118     
119 }
120 #pragma mark - LWTEditViewControllerDelegate
121 - (void)editViewControllerSaveBtnClick:(LWTEditViewController *)editViewController andContact:(LWTContactModel *)contact
122 {
123     // 更新保存的数据
124     [NSKeyedArchiver archiveRootObject:self.contacts toFile:KARCPath];
125     // 刷新表格
126     [self.tableView reloadData];
127 }
128 
129 - (IBAction)loginOutBtnOnClick:(UIBarButtonItem *)sender {
130     
131     UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"确认退出吗?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles: nil];
132     [sheet showInView:self.view];
133 }
134 #pragma mark - UIActionSheetDelegate
135 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
136 {
137     if (0 == buttonIndex) {
138         [self.navigationController popToRootViewControllerAnimated:YES];
139     }
140 }
141 
142 @end
View Code
bubuko.com,布布扣

LWTAddViewController.h

bubuko.com,布布扣
bubuko.com,布布扣
#import <UIKit/UIKit.h>
@class LWTAddViewController, LWTContactModel;

@protocol LWTAddViewControllerDelegate <NSObject>

@optional
- (void)addViewControllerAddBtnClick : (LWTAddViewController *)addViewCOntroller andContact : (LWTContactModel *)contact;

@end

@interface LWTAddViewController : UIViewController

@property (nonatomic, strong) id<LWTAddViewControllerDelegate> delegate;

@end
View Code
bubuko.com,布布扣

LWTAddViewController.m

bubuko.com,布布扣
bubuko.com,布布扣
 1 //
 2 //  LWTAddViewController.m
 3 //  多控制器管理联系 -- 私人通讯录
 4 //
 5 //  Created by apple on 14-6-7.
 6 //  Copyright (c) 2014年 lwt. All rights reserved.
 7 //
 8 
 9 #import "LWTAddViewController.h"
10 #import "LWTContactModel.h"
11 
12 @interface LWTAddViewController ()
13 /**
14  *  姓名输入框
15  */
16 @property (weak, nonatomic) IBOutlet UITextField *nameField;
17 /**
18  *  电话输入框
19  */
20 @property (weak, nonatomic) IBOutlet UITextField *phoneField;
21 /**
22  *  添加按钮
23  */
24 @property (weak, nonatomic) IBOutlet UIButton *addBtn;
25 /**
26  *  点击添加按钮
27  */
28 - (IBAction)addBtnOnClick:(UIButton *)sender;
29 
30 @end
31 
32 @implementation LWTAddViewController
33 
34 - (void)viewDidLoad
35 {
36     // 监听文本输入框的改变
37     // 拿到通知中心
38     NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
39     // 注册监听
40     [center addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.nameField];
41     [center addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.phoneField];
42 
43 }
44 
45 - (void)dealloc
46 {
47     [[NSNotificationCenter defaultCenter] removeObserver:self];
48 }
49 
50 - (void)textChange
51 {
52     self.addBtn.enabled = (self.nameField.text.length >0 && self.phoneField.text.length > 0);
53 }
54 
55 - (void)viewDidAppear:(BOOL)animated
56 {
57     // 弹出键盘
58     [self.nameField becomeFirstResponder];
59 }
60 
61 - (IBAction)addBtnOnClick:(UIButton *)sender {
62     // 移除栈顶控制器
63     [self.navigationController popViewControllerAnimated:YES];
64     
65     // 获取用户输入的姓名和电话
66     LWTContactModel *contact = [[LWTContactModel alloc] init];
67     contact.name = self.nameField.text;
68     contact.phone = self.phoneField.text;
69     
70     // 传递数据给联系人列表
71     if ([self.delegate respondsToSelector:@selector(addViewControllerAddBtnClick:andContact:)]) {
72         [self.delegate addViewControllerAddBtnClick:self andContact:contact];
73     }
74 }
75 @end
View Code
bubuko.com,布布扣

LWTEditViewController.h

bubuko.com,布布扣
bubuko.com,布布扣
#import <UIKit/UIKit.h>
@class LWTContactModel, LWTEditViewController;

@protocol LWTEditViewControllerDelegate <NSObject>

@optional
- (void)editViewControllerSaveBtnClick : (LWTEditViewController *)editViewController andContact : (LWTContactModel *)contact;

@end

@interface LWTEditViewController : UIViewController

@property (nonatomic, strong) id<LWTEditViewControllerDelegate> delegate;
/**
 *  用于接收联系人列表传递过来的数据
 */
@property (nonatomic, strong) LWTContactModel *contact;

@end
View Code
bubuko.com,布布扣

LWTEditViewController.m

bubuko.com,布布扣
bubuko.com,布布扣
  1 //
  2 //  LWTEditViewController.m
  3 //  多控制器管理联系 -- 私人通讯录
  4 //
  5 //  Created by apple on 14-6-7.
  6 //  Copyright (c) 2014年 lwt. All rights reserved.
  7 //
  8 
  9 #import "LWTEditViewController.h"
 10 #import "LWTContactModel.h"
 11 
 12 @interface LWTEditViewController ()
 13 
 14 @property (weak, nonatomic) IBOutlet UITextField *nameField;
 15 @property (weak, nonatomic) IBOutlet UITextField *phoneField;
 16 @property (weak, nonatomic) IBOutlet UIButton *saveBtn;
 17 
 18 /**
 19  *  保存按钮点击事件
 20  */
 21 - (IBAction)saveBtnOnClick:(UIButton *)sender;
 22 /**
 23  *  编辑按钮点击事件
 24  */
 25 - (IBAction)editBtnOnClick:(UIBarButtonItem *)sender;
 26 
 27 @end
 28 
 29 @implementation LWTEditViewController
 30 
 31 - (void)viewDidLoad
 32 {
 33     // 监听文本输入框的改变
 34     // 拿到通知中心
 35     NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
 36     // 注册监听
 37     [center addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.nameField];
 38     [center addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.phoneField];
 39     
 40     // 设置姓名文本输入框
 41     self.nameField.text = self.contact.name;
 42     // 设置电话文本输入框
 43     self.phoneField.text = self.contact.phone;
 44     
 45 }
 46 
 47 - (void)dealloc
 48 {
 49     [[NSNotificationCenter defaultCenter] removeObserver:self];
 50 }
 51 
 52 - (void)textChange
 53 {
 54     self.saveBtn.enabled = (self.nameField.text.length >0 && self.phoneField.text.length > 0);
 55 }
 56 
 57 - (IBAction)saveBtnOnClick:(UIButton *)sender {
 58     // 移除栈顶控制器
 59     [self.navigationController popViewControllerAnimated:YES];
 60     // 修改模型数据
 61     self.contact.name = self.nameField.text;
 62     self.contact.phone = self.phoneField.text;
 63     // 通知代理
 64     if ([self.delegate respondsToSelector:@selector(editViewControllerSaveBtnClick:andContact:)]) {
 65         [self.delegate editViewControllerSaveBtnClick:self andContact:self.contact];
 66     }
 67 }
 68 
 69 - (IBAction)editBtnOnClick:(UIBarButtonItem *)sender {
 70     if (self.nameField.enabled) {
 71         // 当前是编辑状态
 72         // 让文本输入框不可以交互
 73         self.nameField.enabled = NO;
 74         self.phoneField.enabled = NO;
 75         // 隐藏保存按钮
 76         self.saveBtn.hidden = YES;
 77         // 修改按钮标题
 78         sender.title = @"编辑";
 79         // 让键盘消失
 80         [self.view endEditing:YES];
 81         
 82         // 还原数据
 83         self.nameField.text = self.contact.name;
 84         self.phoneField.text = self.contact.phone;
 85     }else
 86     {
 87         // 当前是不可以编辑状态
 88         // 让文本输入框可以交互
 89         self.nameField.enabled = YES;
 90         self.phoneField.enabled = YES;
 91         // 显示保存按钮
 92         self.saveBtn.hidden = NO;
 93         // 修改按钮标题
 94         sender.title = @"取消";
 95         // 弹出键盘
 96         [self.phoneField becomeFirstResponder];
 97         
 98         
 99     }
100 }
101 @end
View Code
bubuko.com,布布扣

LWTContactModel.h

bubuko.com,布布扣
bubuko.com,布布扣
#import <Foundation/Foundation.h>

@interface LWTContactModel : NSObject <NSCoding>

@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *phone;

@end
View Code
bubuko.com,布布扣

LWTContactModel.m

bubuko.com,布布扣
bubuko.com,布布扣
//
//  LWTContactModel.m
//  多控制器管理联系 -- 私人通讯录
//
//  Created by apple on 14-6-8.
//  Copyright (c) 2014年 lwt. All rights reserved.
//

#import "LWTContactModel.h"
#define KName @"name"
#define KPhone @"phone"

@implementation LWTContactModel

 - (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.name forKey:KName];
    [aCoder encodeObject:self.phone forKey:KPhone];

}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {
        self.name = [aDecoder decodeObjectForKey:KName];
        self.phone = [aDecoder decodeObjectForKey:KPhone];
    }
    return self;
}



@end
View Code
bubuko.com,布布扣

LWTContactCell.h

bubuko.com,布布扣
bubuko.com,布布扣
#import <UIKit/UIKit.h>
@class LWTContactModel;

@interface LWTContactCell : UITableViewCell

+ (instancetype)contactCellWithTableView : (UITableView *)tableView;

@property (nonatomic, strong) LWTContactModel *contact;

@end
View Code
bubuko.com,布布扣

LWTContactCell.m

bubuko.com,布布扣
bubuko.com,布布扣
 1 //
 2 //  LWTContactCell.m
 3 //  多控制器管理联系 -- 私人通讯录
 4 //
 5 //  Created by apple on 14-6-8.
 6 //  Copyright (c) 2014年 lwt. All rights reserved.
 7 //
 8 
 9 #import "LWTContactCell.h"
10 #import "LWTContactModel.h"
11 
12 @interface LWTContactCell ()
13 @property (nonatomic, weak) UIView *divider;
14 
15 @end
16 
17 @implementation LWTContactCell
18 
19 + (instancetype)contactCellWithTableView:(UITableView *)tableView
20 {
21     NSString *identfier = @"contacts";
22     LWTContactCell *cell = [tableView dequeueReusableCellWithIdentifier:identfier];
23     return cell;
24 }
25 
26 - (void)setContact:(LWTContactModel *)contact
27 {
28     
29     _contact = contact;
30     // 设置名称
31     self.textLabel.text = _contact.name;
32     // 设置电话
33     self.detailTextLabel.text = _contact.phone;
34 }
35 
36 - (void)awakeFromNib
37 {
38     // 创建分割线添加到cell中
39     UIView *view = [[UIView alloc] init];
40     view.backgroundColor = [UIColor grayColor];
41     view.alpha = 0.5;
42     
43     self.divider = view;
44     
45     [self.contentView addSubview:view];
46     
47 }
48 
49 - (void)layoutSubviews
50 {
51     [super layoutSubviews];
52     CGFloat x = 0;
53     CGFloat w = self.bounds.size.width;
54     CGFloat h = 1;
55     CGFloat y = self.bounds.size.height - h;
56     
57     // 设置分割线的frame
58     self.divider.frame = CGRectMake(x, y, w, h);
59 }
60 
61 @end
View Code
bubuko.com,布布扣

多控制器管理练习 -- 私人通讯录,布布扣,bubuko.com

多控制器管理练习 -- 私人通讯录

标签:des   c   style   class   blog   code   

原文地址:http://www.cnblogs.com/wentianblog/p/3776265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!