HYweibo Development Record

1.HYweibo envirment setup

1.1. Create Git resposery on Github

1.2. Clone to workspace with Github Desktop

1.3. Create new single view app

Snip20181123_44

1.4. and Push as a start point

1.5. delete auto created files

Snip20181123_45

1.6. set main interface and orientation

Snip20181123_48

1.7. edit HYAppDelegate.m

1.7.1 this code make the app runnable and show a tabBar view

Snip20181123_51

Snip20181123_50

1.8 add images

1.8.1 add icon images

Snip20181123_55

1.8.2 add lunch image

Snip20181123_60

1.9. set statusbar

1.9.1. set to hide during launch

Snip20181123_61

1.9.2. set to show after launch

Snip20181123_63

2. Show child viewContorllers

2.1. noob way-write code in AppDelegate

Snip20181123_65

2.2. right way-use custom TabBarContrller

2.2.1. create custom TabBarContrller class

Snip20181123_67

2.2.2. use instance of TabBarController

Snip20181123_69

2.2.3. add tabBar button images

Snip20181123_70

Snip20181123_71

2.2.4. set tabBarItem image

Snip20181124_1

Snip20181124_2

2.2.5 use method to reduce repeated code

Snip20181124_3

Snip20181124_6

2.2.6define macro of random color in pch

Snip20181124_4

Snip20181124_5

2.2.7 add title to tabBarItem

Snip20181124_12

Snip20181124_9

2.2.8. disable auto-render when tabBarItem selected

2.2.8.1. wrong way- won’t work

Snip20181124_13

2.2.8.2. right way- worked

Snip20181124_15

Snip20181124_16

2.2.8.3. apply to right systemVersion >= 7.0

Snip20181124_20

Snip20181124_21

Snip20181124_22

2.2.9 we use UIImage extension to determine image

Snip20181124_8

3. Make dir for modules

3.1. create custom VCs

Snip20181124_10

3.2. use VC in TabBarController

Snip20181124_9

4. add navigation Contrller

4.1 original NVC and title for navigationItem

Snip20181124_19

Snip20181124_24Snip20181124_19

4.2. add test data to tableView

Snip20181125_25

Snip20181125_26

Snip20181125_27

Snip20181125_28

4.3. push new VC when row selected

Snip20181125_29

Snip20181125_30

4.4. hide bottom bar

Snip20181125_33

Snip20181125_34

4.5. Custom navagation controller

4.5.1 whithout judgement all controllers hide bottomBar

Snip20181125_35

Snip20181125_36

4.5.2. judge if it is the Bottom of Stack

Snip20181125_40

Snip20181125_41

Snip20181125_34

5. Set navigationBarItem for pushed Controller

5.1. Add images for navigationBarItem

5.2. Set navigationItem with Library methodSnip20181126_2

5.3. set highlighted image for navigationItem with custom button

Snip20181126_4

setImage 和 setBackgroundImage 区别

5.4. using Extention put this method to Class UIBarButtonItem

Code

Snip20181126_30

A bug cuased No responding by method mistaken from touchUpInSide to touchUpOutside.

Snip20181126_33

5.5. add debug Log macro

Snip20181126_23

Snip20181126_24

Snip20181126_25

5.6. use custom NaviCongroller set NavigationItem for some pushed Controllers

Snip20181126_32

Snip20181126_31

6. Set navigationBarItem for Message Controller

6.1. Xcode viewDidLoad template code function

6.1.1. EditButtonItem

Snip20181126_34

Snip20181126_35

6.1.2. Preserve selection between presentations.

Snip20181126_37

Snip20181126_38

6.2. Custom button as view in barItem

Snip20181126_42

6.3. Use appearance set textLable UItextAttribute

6.3.1. use tintColor, can set only once

6.3.2. Use appearance set textLable UItextAttribute, set once , apply to all BarButtonItems

6.3.3. can use another attributes to set hightlighted theme

6.3.4. UITextAttribute is prefered to tintcolor

6.3.5. tintColor can’t overide attributes

Snip20181126_46

Snip20181126_47

6.3.6. set disabled color

Snip20181126_50

Snip20181126_48

6.3.7 set to disabled from lunch

Snip20181126_53

6.3.8. this line will load all childVCs , without this line will lazyload

Snip20181126_56

6.3.9. put the one-time setting to class init of navigateController

Snip20181126_59

6.4 Add textView, this can test setting barButtonItem

Snip20181126_62

Snip20181126_60

6.5. Add toolbar for text view

Snip20181126_64

Snip20181126_63

Snip20181126_65

7. setupNavigationBarTheme

7.1.Set navigation bar background

7.1.1.Before set

Snip20181127_5

Snip20181127_2

7.1.2.Set background image for navigation bar for iOS6 with default iOS7’s color

Snip20181127_13

7.2.Set statusBarStyle

Snip20181127_9

7.3.Set navigation bar title

Snip20181127_10

7.3.4.use exist attr as template

Snip20181127_12

8.Add search bar For Discovery

8.1.Use UISearchBar

Snip20181128_12

8.2.Set titleView with Custom TextFiled

Snip20181129_5

8.3.TextField frame, background,contentVerticalAlignment

Snip20181129_8

8.4.strechableImageWithleftCapWidth

Snip20181129_9

8.5.clearButtonMode to show ClearButton (default hides).

Snip20181129_10

8.6.Set leftView image/frame/contentMode for textField

Snip20181129_13

8.7.leftViewMode to show leftView (default hides).

Snip20181129_14

Snip20181129_15

8.8.Set titleView with Custom HYSearchBar Class

Snip20181129_16

Snip20181129_17

Snip20181129_19

9.Add TitleButton For HomeView

9.1.Add TitleButton With UIButton

Snip20181129_7

9.2.Add TitleButton With Custom UIButton

9.3.titleRectForContentRect Set title/image frame

Snip20181129_11

9.4.encapulate stable propertySnip20181129_12

Snip20181129_20

Snip20181129_21

Snip20181129_22

10.Add PopMenu for HomePage

10.1.Define property

Snip20181129_23

10.2.initializer method

Snip20181129_24

10.3.initWithFrame:

Snip20181129_25

10.3.1.add cover button

Snip20181129_30

10.3.2.add container imageView

Snip20181129_32

10.3.3.Set cover frame

Snip20181129_33

10.3.4.Conveniet initializer

Snip20181129_34

10.3.5.Conveniet initializer

Snip20181129_35

10.4.Set frame and detail layout subviews

Snip20181129_37

10.5.dismiss

Snip20181129_38

10.6.add dim background

Snip20181129_39

10.7.add protocol for delgate to set title button

Snip20181129_40

10.7.2.implematation of delegate method

Snip20181129_41

Snip20181129_42

10.7.3.using delgate method to set arrow

Snip20181129_48

10.8.showPopMenu in HomePage

Snip20181129_43

10.9.add method to set container background

Snip20181129_44

10.10.set arrow position

Snip20181129_46

Snip20181129_45

Snip20181129_47

10.10.1.switch break; missing cause wrong

11.Custom TabBar

11.1.Log to show if replace tabBar success

Snip20181201_1

11.2.KVC SET VALUE FOR READONLY property

Snip20181201_3

11.3.Set frame for tabBarButton

Snip20181201_5

11.4.Add Compose button

Snip20181201_6

11.5.Set frame for compose button

Snip20181201_13

11.6.UITabBarControllerDelegate monitor tabBar selection

Snip20181201_8

11.7.Set tabBar background

Snip20181201_9

Snip20181201_11

11.8.Add protocol delegate for monitor compose click

Snip20181201_18

11.9.monitor click event, send message to delegate, let delegate deal

Snip20181201_17

11.10.Add composeViewController

Snip20181202_2

11.11.Present Compose Controller with delegate monitor method

Snip20181202_3

Snip20181202_4

12.New Feature

12.1.read last version

12.2.read current version

12.3.Create HYNewFeatureViewController

12.4.compare version

12.5.if is new version, show new version controller

12.6.save version to defaults

Snip20181202_5

12.7.CFStringRef to NSString

Snip20181202_6

13.NewFeatureViewController

13.1.setupScrollView

13.1.1.add UIScrollView

Snip20181202_7

13.1.2.add images

Snip20181202_8

13.1.3.set scrollView property

Snip20181202_9

Snip20181202_10

13.2.setupPageControl

13.2.1.add page Control

Snip20181202_13

13.2.2.set indicator tint color

Snip20181202_12

Snip20181202_14

13.3.set current page indicator with delegate method!

Snip20181202_11

Snip20181202_15

13.4.setupLastImageView

13.4.1.setupStartButton

Snip20181202_19

13.4.2.change to new TabBarController

Snip20181203_6

Snip20181202_16

Snip20181202_17

13.4.2.1attr[UITextAttributeTextShadowOffset]= [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]; cant repace with NSShadowAttributeName directly.

13.5.setupShareButton

Snip20181203_2

Snip20181203_3

13.6.chage button selected to change image

Snip20181203_4

14.OAuth2.0 authorization

Snip20181203_7

14.1.Register weibo 大有微博

App Key:

App Secret:

授权回调页:

14.2.OAuthViewController

14.2.1.add webView

Snip20181203_9

14.2.2.Load Request

Snip20181203_10

14.2.3.set delegate

Snip20181203_11

14.3.Intercept code by monitor every request

14.3.1.url string from request

Snip20181203_12

14.3.2.get requeset code

14.3.3.get accessToken with code

14.3.4.MBProgressHUD

Snip20181203_13

14.4.accessTokenWithCode

14.4.1.AFHTTPRequestOperationManager

Snip20181203_15

14.4.2.Request params

14.4.3.Send Post Request

Snip20181203_17

14.4.4.Save responseObject

Snip20181203_18

14.4.5.Replace controller

Snip20181203_19

14.4.6.Check if there is an account

Snip20181203_20

15.HYAccount Model

15.1.HYAccount Model properties

Snip20181204_1

15.2.accountWithDict

Snip20181204_2

15.3.initWithCoder decode object from file

Snip20181204_3

15.4.encodeWithCoder code object to save to file

Snip20181204_4

16.Account archive and unarchive tool

16.1.archive objcet to file

Snip20181204_5

16.2.unachive account from archived file

Snip20181204_6

16.2.1.compare date

16.3.Use Model account and Tool accountTool in accessTokenWithCode

Snip20181204_13

17.choose root view controller

Snip20181204_16

17.1.must make key first so HYControllerTool can use window

Snip20181204_10

18.Load Status for HomeView

Snip20181204_9

18.1.loadNewStatus

Snip20181204_17

18.2.set rows with statuses

Snip20181204_18

18.3.use statuses set cell

Snip20181204_20

102.在设置里面调用storyboard创建休息控制器

102.1.HYProfileViewController(要传storyboard identifier,不是vc名)

Snip20200627_2

102.2 通过标识符找到对应的页面(identifier和storyboard名要一致)

Snip20200627_3

103.二维码生成

104.二维码扫描