HYweibo Development Record Posted on 2018-11-23 | Post modified: 2020-06-28 | In iOS | Words count in article: 1.2k | Reading time ≈ 7 1.HYweibo envirment setup 1.1. Create Git resposery on Github1.2. Clone to workspace with Github Desktop1.3. Create new single view app 1.4. and Push as a start point1.5. delete auto created files 1.6. set main interface and orientation 1.7. edit HYAppDelegate.m1.7.1 this code make the app runnable and show a tabBar view 1.8 add images1.8.1 add icon images 1.8.2 add lunch image 1.9. set statusbar1.9.1. set to hide during launch 1.9.2. set to show after launch 2. Show child viewContorllers2.1. noob way-write code in AppDelegate 2.2. right way-use custom TabBarContrller2.2.1. create custom TabBarContrller class 2.2.2. use instance of TabBarController 2.2.3. add tabBar button images 2.2.4. set tabBarItem image 2.2.5 use method to reduce repeated code 2.2.6define macro of random color in pch 2.2.7 add title to tabBarItem 2.2.8. disable auto-render when tabBarItem selected2.2.8.1. wrong way- won’t work 2.2.8.2. right way- worked 2.2.8.3. apply to right systemVersion >= 7.0 2.2.9 we use UIImage extension to determine image 3. Make dir for modules3.1. create custom VCs 3.2. use VC in TabBarController 4. add navigation Contrller4.1 original NVC and title for navigationItem 4.2. add test data to tableView 4.3. push new VC when row selected 4.4. hide bottom bar 4.5. Custom navagation controller4.5.1 whithout judgement all controllers hide bottomBar 4.5.2. judge if it is the Bottom of Stack 5. Set navigationBarItem for pushed Controller5.1. Add images for navigationBarItem5.2. Set navigationItem with Library method5.3. set highlighted image for navigationItem with custom button setImage 和 setBackgroundImage 区别5.4. using Extention put this method to Class UIBarButtonItemCode A bug cuased No responding by method mistaken from touchUpInSide to touchUpOutside. 5.5. add debug Log macro 5.6. use custom NaviCongroller set NavigationItem for some pushed Controllers 6. Set navigationBarItem for Message Controller6.1. Xcode viewDidLoad template code function6.1.1. EditButtonItem 6.1.2. Preserve selection between presentations. 6.2. Custom button as view in barItem 6.3. Use appearance set textLable UItextAttribute6.3.1. use tintColor, can set only once6.3.2. Use appearance set textLable UItextAttribute, set once , apply to all BarButtonItems6.3.3. can use another attributes to set hightlighted theme6.3.4. UITextAttribute is prefered to tintcolor6.3.5. tintColor can’t overide attributes 6.3.6. set disabled color 6.3.7 set to disabled from lunch 6.3.8. this line will load all childVCs , without this line will lazyload 6.3.9. put the one-time setting to class init of navigateController 6.4 Add textView, this can test setting barButtonItem 6.5. Add toolbar for text view 7. setupNavigationBarTheme7.1.Set navigation bar background7.1.1.Before set 7.1.2.Set background image for navigation bar for iOS6 with default iOS7’s color 7.2.Set statusBarStyle 7.3.Set navigation bar title 7.3.4.use exist attr as template 8.Add search bar For Discovery8.1.Use UISearchBar 8.2.Set titleView with Custom TextFiled 8.3.TextField frame, background,contentVerticalAlignment 8.4.strechableImageWithleftCapWidth 8.5.clearButtonMode to show ClearButton (default hides). 8.6.Set leftView image/frame/contentMode for textField 8.7.leftViewMode to show leftView (default hides). 8.8.Set titleView with Custom HYSearchBar Class 9.Add TitleButton For HomeView9.1.Add TitleButton With UIButton 9.2.Add TitleButton With Custom UIButton9.3.titleRectForContentRect Set title/image frame 9.4.encapulate stable property 10.Add PopMenu for HomePage10.1.Define property 10.2.initializer method 10.3.initWithFrame: 10.3.1.add cover button 10.3.2.add container imageView 10.3.3.Set cover frame 10.3.4.Conveniet initializer 10.3.5.Conveniet initializer 10.4.Set frame and detail layout subviews 10.5.dismiss 10.6.add dim background 10.7.add protocol for delgate to set title button 10.7.2.implematation of delegate method 10.7.3.using delgate method to set arrow 10.8.showPopMenu in HomePage 10.9.add method to set container background 10.10.set arrow position 10.10.1.switch break; missing cause wrong11.Custom TabBar11.1.Log to show if replace tabBar success 11.2.KVC SET VALUE FOR READONLY property 11.3.Set frame for tabBarButton 11.4.Add Compose button 11.5.Set frame for compose button 11.6.UITabBarControllerDelegate monitor tabBar selection 11.7.Set tabBar background 11.8.Add protocol delegate for monitor compose click 11.9.monitor click event, send message to delegate, let delegate deal 11.10.Add composeViewController 11.11.Present Compose Controller with delegate monitor method 12.New Feature12.1.read last version12.2.read current version12.3.Create HYNewFeatureViewController12.4.compare version12.5.if is new version, show new version controller12.6.save version to defaults 12.7.CFStringRef to NSString 13.NewFeatureViewController13.1.setupScrollView13.1.1.add UIScrollView 13.1.2.add images 13.1.3.set scrollView property 13.2.setupPageControl13.2.1.add page Control 13.2.2.set indicator tint color 13.3.set current page indicator with delegate method! 13.4.setupLastImageView13.4.1.setupStartButton 13.4.2.change to new TabBarController 13.4.2.1attr[UITextAttributeTextShadowOffset]= [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]; cant repace with NSShadowAttributeName directly.13.5.setupShareButton 13.6.chage button selected to change image 14.OAuth2.0 authorization 14.1.Register weibo 大有微博App Key:App Secret:授权回调页:14.2.OAuthViewController14.2.1.add webView 14.2.2.Load Request 14.2.3.set delegate 14.3.Intercept code by monitor every request14.3.1.url string from request 14.3.2.get requeset code14.3.3.get accessToken with code14.3.4.MBProgressHUD 14.4.accessTokenWithCode14.4.1.AFHTTPRequestOperationManager 14.4.2.Request params14.4.3.Send Post Request 14.4.4.Save responseObject 14.4.5.Replace controller 14.4.6.Check if there is an account 15.HYAccount Model15.1.HYAccount Model properties 15.2.accountWithDict 15.3.initWithCoder decode object from file 15.4.encodeWithCoder code object to save to file 16.Account archive and unarchive tool16.1.archive objcet to file 16.2.unachive account from archived file 16.2.1.compare date16.3.Use Model account and Tool accountTool in accessTokenWithCode 17.choose root view controller 17.1.must make key first so HYControllerTool can use window 18.Load Status for HomeView 18.1.loadNewStatus 18.2.set rows with statuses 18.3.use statuses set cell 102.在设置里面调用storyboard创建休息控制器102.1.HYProfileViewController(要传storyboard identifier,不是vc名) 102.2 通过标识符找到对应的页面(identifier和storyboard名要一致)103.二维码生成104.二维码扫描