mainview
@@ -8,6 +8,9 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
63816045C89E43DD9F96396F /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C7B3792862C24377B1ACD469 /* libPods.a */; };
|
||||
A9AA325A199702DB000BE4FB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9AA3259199702DB000BE4FB /* Images.xcassets */; };
|
||||
A9AA326019970335000BE4FB /* HomeAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AA325D19970335000BE4FB /* HomeAdView.m */; };
|
||||
A9AA326119970335000BE4FB /* ImagePlayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AA325F19970335000BE4FB /* ImagePlayerView.m */; };
|
||||
A9AF6BED19947DD00076C0EE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AF6BEC19947DD00076C0EE /* Foundation.framework */; };
|
||||
A9AF6BEF19947DD00076C0EE /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AF6BEE19947DD00076C0EE /* CoreGraphics.framework */; };
|
||||
A9AF6BF119947DD00076C0EE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AF6BF019947DD00076C0EE /* UIKit.framework */; };
|
||||
@@ -16,7 +19,6 @@
|
||||
A9AF6BFD19947DD00076C0EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6BFC19947DD00076C0EE /* AppDelegate.m */; };
|
||||
A9AF6C0019947DD00076C0EE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6BFE19947DD00076C0EE /* Main.storyboard */; };
|
||||
A9AF6C0319947DD00076C0EE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C0219947DD00076C0EE /* ViewController.m */; };
|
||||
A9AF6C0519947DD00076C0EE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C0419947DD00076C0EE /* Images.xcassets */; };
|
||||
A9AF6C0C19947DD10076C0EE /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AF6C0B19947DD10076C0EE /* XCTest.framework */; };
|
||||
A9AF6C0D19947DD10076C0EE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AF6BEC19947DD00076C0EE /* Foundation.framework */; };
|
||||
A9AF6C0E19947DD10076C0EE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AF6BF019947DD00076C0EE /* UIKit.framework */; };
|
||||
@@ -32,6 +34,40 @@
|
||||
A9AF6C43199498C40076C0EE /* MyViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C41199498C40076C0EE /* MyViewController.xib */; };
|
||||
A9AF6C47199498D10076C0EE /* MoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C45199498D10076C0EE /* MoreViewController.m */; };
|
||||
A9AF6C48199498D10076C0EE /* MoreViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C46199498D10076C0EE /* MoreViewController.xib */; };
|
||||
A9AF6C5C19949CD30076C0EE /* icon_dock_forum_actived@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C4E19949CD30076C0EE /* icon_dock_forum_actived@2x.png */; };
|
||||
A9AF6C5D19949CD30076C0EE /* icon_dock_forum@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C4F19949CD30076C0EE /* icon_dock_forum@2x.png */; };
|
||||
A9AF6C5E19949CD30076C0EE /* icon_dock_home_actived@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5019949CD30076C0EE /* icon_dock_home_actived@2x.png */; };
|
||||
A9AF6C5F19949CD30076C0EE /* icon_dock_home@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5119949CD30076C0EE /* icon_dock_home@2x.png */; };
|
||||
A9AF6C6019949CD30076C0EE /* icon_dock_mine_actived@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5219949CD30076C0EE /* icon_dock_mine_actived@2x.png */; };
|
||||
A9AF6C6119949CD30076C0EE /* icon_dock_mine@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5319949CD30076C0EE /* icon_dock_mine@2x.png */; };
|
||||
A9AF6C6219949CD30076C0EE /* icon_dock_rt_actived@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5419949CD30076C0EE /* icon_dock_rt_actived@2x.png */; };
|
||||
A9AF6C6319949CD30076C0EE /* icon_dock_rt@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5519949CD30076C0EE /* icon_dock_rt@2x.png */; };
|
||||
A9AF6C6419949CD30076C0EE /* icon_dock_service_actived@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5619949CD30076C0EE /* icon_dock_service_actived@2x.png */; };
|
||||
A9AF6C6519949CD30076C0EE /* icon_dock_service@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5719949CD30076C0EE /* icon_dock_service@2x.png */; };
|
||||
A9AF6C6619949CD30076C0EE /* icon_dock_session_actived_msg@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5819949CD30076C0EE /* icon_dock_session_actived_msg@2x.png */; };
|
||||
A9AF6C6719949CD30076C0EE /* icon_dock_session_actived@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5919949CD30076C0EE /* icon_dock_session_actived@2x.png */; };
|
||||
A9AF6C6819949CD30076C0EE /* icon_dock_session_msg@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5A19949CD30076C0EE /* icon_dock_session_msg@2x.png */; };
|
||||
A9AF6C6919949CD30076C0EE /* icon_dock_session@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C5B19949CD30076C0EE /* icon_dock_session@2x.png */; };
|
||||
A9AF6C721994B5890076C0EE /* icon_bar_card@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C6A1994B5890076C0EE /* icon_bar_card@2x.png */; };
|
||||
A9AF6C731994B5890076C0EE /* icon_bar_share@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C6B1994B5890076C0EE /* icon_bar_share@2x.png */; };
|
||||
A9AF6C741994B5890076C0EE /* icon_indicate_add_module@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C6C1994B5890076C0EE /* icon_indicate_add_module@2x.png */; };
|
||||
A9AF6C751994B5890076C0EE /* icon_indicate_arrow_don@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C6D1994B5890076C0EE /* icon_indicate_arrow_don@2x.png */; };
|
||||
A9AF6C761994B5890076C0EE /* icon_indicate_more_down@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C6E1994B5890076C0EE /* icon_indicate_more_down@2x.png */; };
|
||||
A9AF6C771994B5890076C0EE /* icon_indicate_more@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C6F1994B5890076C0EE /* icon_indicate_more@2x.png */; };
|
||||
A9AF6C781994B5890076C0EE /* icon_share_default.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C701994B5890076C0EE /* icon_share_default.png */; };
|
||||
A9AF6C791994B5890076C0EE /* tabbarShadowImage@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C711994B5890076C0EE /* tabbarShadowImage@2x.png */; };
|
||||
A9AF6C8F1994C5700076C0EE /* MJRefresh.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C7F1994C5700076C0EE /* MJRefresh.bundle */; };
|
||||
A9AF6C901994C5700076C0EE /* MJRefreshBaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C821994C5700076C0EE /* MJRefreshBaseView.m */; };
|
||||
A9AF6C911994C5700076C0EE /* MJRefreshConst.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C841994C5700076C0EE /* MJRefreshConst.m */; };
|
||||
A9AF6C921994C5700076C0EE /* MJRefreshFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C861994C5700076C0EE /* MJRefreshFooterView.m */; };
|
||||
A9AF6C931994C5700076C0EE /* MJRefreshHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C881994C5700076C0EE /* MJRefreshHeaderView.m */; };
|
||||
A9AF6C941994C5700076C0EE /* UIScrollView+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C8A1994C5700076C0EE /* UIScrollView+Extension.m */; };
|
||||
A9AF6C951994C5700076C0EE /* UIScrollView+MJRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C8C1994C5700076C0EE /* UIScrollView+MJRefresh.m */; };
|
||||
A9AF6C961994C5700076C0EE /* UIView+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AF6C8E1994C5700076C0EE /* UIView+Extension.m */; };
|
||||
A9AF6CA01994D0210076C0EE /* ad1@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6C9F1994D0210076C0EE /* ad1@2x.png */; };
|
||||
A9AF6CA41994D0660076C0EE /* ad2@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6CA11994D0660076C0EE /* ad2@2x.png */; };
|
||||
A9AF6CA51994D0660076C0EE /* ad3@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6CA21994D0660076C0EE /* ad3@2x.png */; };
|
||||
A9AF6CA61994D0660076C0EE /* ad4@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6CA31994D0660076C0EE /* ad4@2x.png */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -46,6 +82,11 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
5730F11CFCAA47EB9D024FB8 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
|
||||
A9AA3259199702DB000BE4FB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
A9AA325C19970335000BE4FB /* HomeAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeAdView.h; sourceTree = "<group>"; };
|
||||
A9AA325D19970335000BE4FB /* HomeAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeAdView.m; sourceTree = "<group>"; };
|
||||
A9AA325E19970335000BE4FB /* ImagePlayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImagePlayerView.h; sourceTree = "<group>"; };
|
||||
A9AA325F19970335000BE4FB /* ImagePlayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImagePlayerView.m; sourceTree = "<group>"; };
|
||||
A9AF6BE919947DD00076C0EE /* ManagerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ManagerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A9AF6BEC19947DD00076C0EE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
A9AF6BEE19947DD00076C0EE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
@@ -59,7 +100,6 @@
|
||||
A9AF6BFF19947DD00076C0EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
A9AF6C0119947DD00076C0EE /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||
A9AF6C0219947DD00076C0EE /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||
A9AF6C0419947DD00076C0EE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
A9AF6C0A19947DD10076C0EE /* ManagerDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ManagerDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A9AF6C0B19947DD10076C0EE /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
|
||||
A9AF6C1319947DD10076C0EE /* ManagerDemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ManagerDemoTests-Info.plist"; sourceTree = "<group>"; };
|
||||
@@ -80,6 +120,49 @@
|
||||
A9AF6C44199498D10076C0EE /* MoreViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoreViewController.h; sourceTree = "<group>"; };
|
||||
A9AF6C45199498D10076C0EE /* MoreViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoreViewController.m; sourceTree = "<group>"; };
|
||||
A9AF6C46199498D10076C0EE /* MoreViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MoreViewController.xib; sourceTree = "<group>"; };
|
||||
A9AF6C4B19949B7B0076C0EE /* ManagerConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ManagerConstants.h; sourceTree = "<group>"; };
|
||||
A9AF6C4E19949CD30076C0EE /* icon_dock_forum_actived@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_forum_actived@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C4F19949CD30076C0EE /* icon_dock_forum@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_forum@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5019949CD30076C0EE /* icon_dock_home_actived@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_home_actived@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5119949CD30076C0EE /* icon_dock_home@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_home@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5219949CD30076C0EE /* icon_dock_mine_actived@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_mine_actived@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5319949CD30076C0EE /* icon_dock_mine@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_mine@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5419949CD30076C0EE /* icon_dock_rt_actived@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_rt_actived@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5519949CD30076C0EE /* icon_dock_rt@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_rt@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5619949CD30076C0EE /* icon_dock_service_actived@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_service_actived@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5719949CD30076C0EE /* icon_dock_service@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_service@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5819949CD30076C0EE /* icon_dock_session_actived_msg@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_session_actived_msg@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5919949CD30076C0EE /* icon_dock_session_actived@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_session_actived@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5A19949CD30076C0EE /* icon_dock_session_msg@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_session_msg@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C5B19949CD30076C0EE /* icon_dock_session@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_dock_session@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C6A1994B5890076C0EE /* icon_bar_card@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_bar_card@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C6B1994B5890076C0EE /* icon_bar_share@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_bar_share@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C6C1994B5890076C0EE /* icon_indicate_add_module@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_indicate_add_module@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C6D1994B5890076C0EE /* icon_indicate_arrow_don@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_indicate_arrow_don@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C6E1994B5890076C0EE /* icon_indicate_more_down@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_indicate_more_down@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C6F1994B5890076C0EE /* icon_indicate_more@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_indicate_more@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C701994B5890076C0EE /* icon_share_default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_share_default.png; sourceTree = "<group>"; };
|
||||
A9AF6C711994B5890076C0EE /* tabbarShadowImage@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tabbarShadowImage@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6C7F1994C5700076C0EE /* MJRefresh.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = MJRefresh.bundle; sourceTree = "<group>"; };
|
||||
A9AF6C801994C5700076C0EE /* MJRefresh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefresh.h; sourceTree = "<group>"; };
|
||||
A9AF6C811994C5700076C0EE /* MJRefreshBaseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefreshBaseView.h; sourceTree = "<group>"; };
|
||||
A9AF6C821994C5700076C0EE /* MJRefreshBaseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJRefreshBaseView.m; sourceTree = "<group>"; };
|
||||
A9AF6C831994C5700076C0EE /* MJRefreshConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefreshConst.h; sourceTree = "<group>"; };
|
||||
A9AF6C841994C5700076C0EE /* MJRefreshConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJRefreshConst.m; sourceTree = "<group>"; };
|
||||
A9AF6C851994C5700076C0EE /* MJRefreshFooterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefreshFooterView.h; sourceTree = "<group>"; };
|
||||
A9AF6C861994C5700076C0EE /* MJRefreshFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJRefreshFooterView.m; sourceTree = "<group>"; };
|
||||
A9AF6C871994C5700076C0EE /* MJRefreshHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefreshHeaderView.h; sourceTree = "<group>"; };
|
||||
A9AF6C881994C5700076C0EE /* MJRefreshHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJRefreshHeaderView.m; sourceTree = "<group>"; };
|
||||
A9AF6C891994C5700076C0EE /* UIScrollView+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+Extension.h"; sourceTree = "<group>"; };
|
||||
A9AF6C8A1994C5700076C0EE /* UIScrollView+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+Extension.m"; sourceTree = "<group>"; };
|
||||
A9AF6C8B1994C5700076C0EE /* UIScrollView+MJRefresh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+MJRefresh.h"; sourceTree = "<group>"; };
|
||||
A9AF6C8C1994C5700076C0EE /* UIScrollView+MJRefresh.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+MJRefresh.m"; sourceTree = "<group>"; };
|
||||
A9AF6C8D1994C5700076C0EE /* UIView+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Extension.h"; sourceTree = "<group>"; };
|
||||
A9AF6C8E1994C5700076C0EE /* UIView+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Extension.m"; sourceTree = "<group>"; };
|
||||
A9AF6C9F1994D0210076C0EE /* ad1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad1@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6CA11994D0660076C0EE /* ad2@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad2@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6CA21994D0660076C0EE /* ad3@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad3@2x.png"; sourceTree = "<group>"; };
|
||||
A9AF6CA31994D0660076C0EE /* ad4@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad4@2x.png"; sourceTree = "<group>"; };
|
||||
C7B3792862C24377B1ACD469 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -108,6 +191,17 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
A9AA325B19970304000BE4FB /* HomeView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9AA325C19970335000BE4FB /* HomeAdView.h */,
|
||||
A9AA325D19970335000BE4FB /* HomeAdView.m */,
|
||||
A9AA325E19970335000BE4FB /* ImagePlayerView.h */,
|
||||
A9AA325F19970335000BE4FB /* ImagePlayerView.m */,
|
||||
);
|
||||
path = HomeView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9AF6BE019947DD00076C0EE = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -143,13 +237,16 @@
|
||||
A9AF6BF219947DD00076C0EE /* ManagerDemo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9AF6C971994C97F0076C0EE /* MainView */,
|
||||
A9AF6C4D19949CAD0076C0EE /* Resource */,
|
||||
A9AF6C4A19949B510076C0EE /* Common */,
|
||||
A9AF6C2A199483470076C0EE /* MainViewControll */,
|
||||
A9AF6BFB19947DD00076C0EE /* AppDelegate.h */,
|
||||
A9AF6BFC19947DD00076C0EE /* AppDelegate.m */,
|
||||
A9AF6BFE19947DD00076C0EE /* Main.storyboard */,
|
||||
A9AF6C0119947DD00076C0EE /* ViewController.h */,
|
||||
A9AF6C0219947DD00076C0EE /* ViewController.m */,
|
||||
A9AF6C0419947DD00076C0EE /* Images.xcassets */,
|
||||
A9AA3259199702DB000BE4FB /* Images.xcassets */,
|
||||
A9AF6BF319947DD00076C0EE /* Supporting Files */,
|
||||
);
|
||||
path = ManagerDemo;
|
||||
@@ -206,6 +303,79 @@
|
||||
path = MainViewControll;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9AF6C4A19949B510076C0EE /* Common */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9AF6C7E1994C5700076C0EE /* MJRefresh */,
|
||||
A9AF6C4B19949B7B0076C0EE /* ManagerConstants.h */,
|
||||
);
|
||||
path = Common;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9AF6C4D19949CAD0076C0EE /* Resource */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9AF6C9F1994D0210076C0EE /* ad1@2x.png */,
|
||||
A9AF6CA11994D0660076C0EE /* ad2@2x.png */,
|
||||
A9AF6CA21994D0660076C0EE /* ad3@2x.png */,
|
||||
A9AF6CA31994D0660076C0EE /* ad4@2x.png */,
|
||||
A9AF6C6A1994B5890076C0EE /* icon_bar_card@2x.png */,
|
||||
A9AF6C6B1994B5890076C0EE /* icon_bar_share@2x.png */,
|
||||
A9AF6C6C1994B5890076C0EE /* icon_indicate_add_module@2x.png */,
|
||||
A9AF6C6D1994B5890076C0EE /* icon_indicate_arrow_don@2x.png */,
|
||||
A9AF6C6E1994B5890076C0EE /* icon_indicate_more_down@2x.png */,
|
||||
A9AF6C6F1994B5890076C0EE /* icon_indicate_more@2x.png */,
|
||||
A9AF6C701994B5890076C0EE /* icon_share_default.png */,
|
||||
A9AF6C711994B5890076C0EE /* tabbarShadowImage@2x.png */,
|
||||
A9AF6C4E19949CD30076C0EE /* icon_dock_forum_actived@2x.png */,
|
||||
A9AF6C4F19949CD30076C0EE /* icon_dock_forum@2x.png */,
|
||||
A9AF6C5019949CD30076C0EE /* icon_dock_home_actived@2x.png */,
|
||||
A9AF6C5119949CD30076C0EE /* icon_dock_home@2x.png */,
|
||||
A9AF6C5219949CD30076C0EE /* icon_dock_mine_actived@2x.png */,
|
||||
A9AF6C5319949CD30076C0EE /* icon_dock_mine@2x.png */,
|
||||
A9AF6C5419949CD30076C0EE /* icon_dock_rt_actived@2x.png */,
|
||||
A9AF6C5519949CD30076C0EE /* icon_dock_rt@2x.png */,
|
||||
A9AF6C5619949CD30076C0EE /* icon_dock_service_actived@2x.png */,
|
||||
A9AF6C5719949CD30076C0EE /* icon_dock_service@2x.png */,
|
||||
A9AF6C5819949CD30076C0EE /* icon_dock_session_actived_msg@2x.png */,
|
||||
A9AF6C5919949CD30076C0EE /* icon_dock_session_actived@2x.png */,
|
||||
A9AF6C5A19949CD30076C0EE /* icon_dock_session_msg@2x.png */,
|
||||
A9AF6C5B19949CD30076C0EE /* icon_dock_session@2x.png */,
|
||||
);
|
||||
path = Resource;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9AF6C7E1994C5700076C0EE /* MJRefresh */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9AF6C7F1994C5700076C0EE /* MJRefresh.bundle */,
|
||||
A9AF6C801994C5700076C0EE /* MJRefresh.h */,
|
||||
A9AF6C811994C5700076C0EE /* MJRefreshBaseView.h */,
|
||||
A9AF6C821994C5700076C0EE /* MJRefreshBaseView.m */,
|
||||
A9AF6C831994C5700076C0EE /* MJRefreshConst.h */,
|
||||
A9AF6C841994C5700076C0EE /* MJRefreshConst.m */,
|
||||
A9AF6C851994C5700076C0EE /* MJRefreshFooterView.h */,
|
||||
A9AF6C861994C5700076C0EE /* MJRefreshFooterView.m */,
|
||||
A9AF6C871994C5700076C0EE /* MJRefreshHeaderView.h */,
|
||||
A9AF6C881994C5700076C0EE /* MJRefreshHeaderView.m */,
|
||||
A9AF6C891994C5700076C0EE /* UIScrollView+Extension.h */,
|
||||
A9AF6C8A1994C5700076C0EE /* UIScrollView+Extension.m */,
|
||||
A9AF6C8B1994C5700076C0EE /* UIScrollView+MJRefresh.h */,
|
||||
A9AF6C8C1994C5700076C0EE /* UIScrollView+MJRefresh.m */,
|
||||
A9AF6C8D1994C5700076C0EE /* UIView+Extension.h */,
|
||||
A9AF6C8E1994C5700076C0EE /* UIView+Extension.m */,
|
||||
);
|
||||
path = MJRefresh;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9AF6C971994C97F0076C0EE /* MainView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9AA325B19970304000BE4FB /* HomeView */,
|
||||
);
|
||||
path = MainView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -285,13 +455,40 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A9AF6C43199498C40076C0EE /* MyViewController.xib in Resources */,
|
||||
A9AF6C731994B5890076C0EE /* icon_bar_share@2x.png in Resources */,
|
||||
A9AF6C6919949CD30076C0EE /* icon_dock_session@2x.png in Resources */,
|
||||
A9AF6C5C19949CD30076C0EE /* icon_dock_forum_actived@2x.png in Resources */,
|
||||
A9AF6CA61994D0660076C0EE /* ad4@2x.png in Resources */,
|
||||
A9AF6C48199498D10076C0EE /* MoreViewController.xib in Resources */,
|
||||
A9AF6C0519947DD00076C0EE /* Images.xcassets in Resources */,
|
||||
A9AF6C6119949CD30076C0EE /* icon_dock_mine@2x.png in Resources */,
|
||||
A9AF6CA51994D0660076C0EE /* ad3@2x.png in Resources */,
|
||||
A9AF6C5E19949CD30076C0EE /* icon_dock_home_actived@2x.png in Resources */,
|
||||
A9AF6C6219949CD30076C0EE /* icon_dock_rt_actived@2x.png in Resources */,
|
||||
A9AF6C781994B5890076C0EE /* icon_share_default.png in Resources */,
|
||||
A9AF6C741994B5890076C0EE /* icon_indicate_add_module@2x.png in Resources */,
|
||||
A9AF6C751994B5890076C0EE /* icon_indicate_arrow_don@2x.png in Resources */,
|
||||
A9AF6C5D19949CD30076C0EE /* icon_dock_forum@2x.png in Resources */,
|
||||
A9AF6C6719949CD30076C0EE /* icon_dock_session_actived@2x.png in Resources */,
|
||||
A9AF6C771994B5890076C0EE /* icon_indicate_more@2x.png in Resources */,
|
||||
A9AA325A199702DB000BE4FB /* Images.xcassets in Resources */,
|
||||
A9AF6C6519949CD30076C0EE /* icon_dock_service@2x.png in Resources */,
|
||||
A9AF6CA01994D0210076C0EE /* ad1@2x.png in Resources */,
|
||||
A9AF6C6019949CD30076C0EE /* icon_dock_mine_actived@2x.png in Resources */,
|
||||
A9AF6C8F1994C5700076C0EE /* MJRefresh.bundle in Resources */,
|
||||
A9AF6C6419949CD30076C0EE /* icon_dock_service_actived@2x.png in Resources */,
|
||||
A9AF6C791994B5890076C0EE /* tabbarShadowImage@2x.png in Resources */,
|
||||
A9AF6BF719947DD00076C0EE /* InfoPlist.strings in Resources */,
|
||||
A9AF6C761994B5890076C0EE /* icon_indicate_more_down@2x.png in Resources */,
|
||||
A9AF6CA41994D0660076C0EE /* ad2@2x.png in Resources */,
|
||||
A9AF6C34199484200076C0EE /* HomeViewController.xib in Resources */,
|
||||
A9AF6C0019947DD00076C0EE /* Main.storyboard in Resources */,
|
||||
A9AF6C3E199486CA0076C0EE /* ProductListViewController.xib in Resources */,
|
||||
A9AF6C2F199483520076C0EE /* MainViewController.xib in Resources */,
|
||||
A9AF6C6319949CD30076C0EE /* icon_dock_rt@2x.png in Resources */,
|
||||
A9AF6C721994B5890076C0EE /* icon_bar_card@2x.png in Resources */,
|
||||
A9AF6C6819949CD30076C0EE /* icon_dock_session_msg@2x.png in Resources */,
|
||||
A9AF6C6619949CD30076C0EE /* icon_dock_session_actived_msg@2x.png in Resources */,
|
||||
A9AF6C5F19949CD30076C0EE /* icon_dock_home@2x.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -343,12 +540,21 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A9AF6C961994C5700076C0EE /* UIView+Extension.m in Sources */,
|
||||
A9AF6C921994C5700076C0EE /* MJRefreshFooterView.m in Sources */,
|
||||
A9AA326019970335000BE4FB /* HomeAdView.m in Sources */,
|
||||
A9AF6C3D199486CA0076C0EE /* ProductListViewController.m in Sources */,
|
||||
A9AF6C941994C5700076C0EE /* UIScrollView+Extension.m in Sources */,
|
||||
A9AF6C47199498D10076C0EE /* MoreViewController.m in Sources */,
|
||||
A9AF6C951994C5700076C0EE /* UIScrollView+MJRefresh.m in Sources */,
|
||||
A9AA326119970335000BE4FB /* ImagePlayerView.m in Sources */,
|
||||
A9AF6C0319947DD00076C0EE /* ViewController.m in Sources */,
|
||||
A9AF6BFD19947DD00076C0EE /* AppDelegate.m in Sources */,
|
||||
A9AF6C911994C5700076C0EE /* MJRefreshConst.m in Sources */,
|
||||
A9AF6C931994C5700076C0EE /* MJRefreshHeaderView.m in Sources */,
|
||||
A9AF6BF919947DD00076C0EE /* main.m in Sources */,
|
||||
A9AF6C33199484200076C0EE /* HomeViewController.m in Sources */,
|
||||
A9AF6C901994C5700076C0EE /* MJRefreshBaseView.m in Sources */,
|
||||
A9AF6C2E199483520076C0EE /* MainViewController.m in Sources */,
|
||||
A9AF6C42199498C40076C0EE /* MyViewController.m in Sources */,
|
||||
);
|
||||
|
||||
@@ -7,12 +7,15 @@
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "MainViewController.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
MainViewController* mainViewController = [[MainViewController alloc] init];
|
||||
self.window.rootViewController = mainViewController;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,27 @@
|
||||
|
||||
#import "UIScrollView+MJRefresh.h"
|
||||
|
||||
/**
|
||||
MJ友情提示:
|
||||
1. 添加头部控件的方法
|
||||
[self.tableView addHeaderWithTarget:self action:@selector(headerRereshing)];
|
||||
或者
|
||||
[self.tableView addHeaderWithCallback:^{ }];
|
||||
|
||||
2. 添加尾部控件的方法
|
||||
[self.tableView addFooterWithTarget:self action:@selector(footerRereshing)];
|
||||
或者
|
||||
[self.tableView addFooterWithCallback:^{ }];
|
||||
|
||||
3. 可以在MJRefreshConst.h和MJRefreshConst.m文件中自定义显示的文字内容和文字颜色
|
||||
|
||||
4. 本框架兼容iOS6\iOS7,iPhone\iPad横竖屏
|
||||
|
||||
5.自动进入刷新状态
|
||||
1> [self.tableView headerBeginRefreshing];
|
||||
2> [self.tableView footerBeginRefreshing];
|
||||
|
||||
6.结束刷新
|
||||
1> [self.tableView headerEndRefreshing];
|
||||
2> [self.tableView footerEndRefreshing];
|
||||
*/
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// MJRefreshBaseView.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 13-3-4.
|
||||
// Copyright (c) 2013年 itcast. All rights reserved.
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class MJRefreshBaseView;
|
||||
|
||||
#pragma mark - 控件的刷新状态
|
||||
typedef enum {
|
||||
MJRefreshStatePulling = 1, // 松开就可以进行刷新的状态
|
||||
MJRefreshStateNormal = 2, // 普通状态
|
||||
MJRefreshStateRefreshing = 3, // 正在刷新中的状态
|
||||
MJRefreshStateWillRefreshing = 4
|
||||
} MJRefreshState;
|
||||
|
||||
#pragma mark - 控件的类型
|
||||
typedef enum {
|
||||
MJRefreshViewTypeHeader = -1, // 头部控件
|
||||
MJRefreshViewTypeFooter = 1 // 尾部控件
|
||||
} MJRefreshViewType;
|
||||
|
||||
/**
|
||||
类的声明
|
||||
*/
|
||||
@interface MJRefreshBaseView : UIView
|
||||
#pragma mark - 父控件
|
||||
@property (nonatomic, weak, readonly) UIScrollView *scrollView;
|
||||
@property (nonatomic, assign, readonly) UIEdgeInsets scrollViewOriginalInset;
|
||||
|
||||
#pragma mark - 内部的控件
|
||||
@property (nonatomic, weak, readonly) UILabel *statusLabel;
|
||||
@property (nonatomic, weak, readonly) UIImageView *arrowImage;
|
||||
@property (nonatomic, weak, readonly) UIActivityIndicatorView *activityView;
|
||||
|
||||
#pragma mark - 回调
|
||||
/**
|
||||
* 开始进入刷新状态的监听器
|
||||
*/
|
||||
@property (weak, nonatomic) id beginRefreshingTaget;
|
||||
/**
|
||||
* 开始进入刷新状态的监听方法
|
||||
*/
|
||||
@property (assign, nonatomic) SEL beginRefreshingAction;
|
||||
/**
|
||||
* 开始进入刷新状态就会调用
|
||||
*/
|
||||
@property (nonatomic, copy) void (^beginRefreshingCallback)();
|
||||
|
||||
#pragma mark - 刷新相关
|
||||
/**
|
||||
* 是否正在刷新
|
||||
*/
|
||||
@property (nonatomic, readonly, getter=isRefreshing) BOOL refreshing;
|
||||
/**
|
||||
* 开始刷新
|
||||
*/
|
||||
- (void)beginRefreshing;
|
||||
/**
|
||||
* 结束刷新
|
||||
*/
|
||||
- (void)endRefreshing;
|
||||
|
||||
#pragma mark - 交给子类去实现 和 调用
|
||||
@property (assign, nonatomic) MJRefreshState state;
|
||||
|
||||
/**
|
||||
* 文字
|
||||
*/
|
||||
@property (copy, nonatomic) NSString *pullToRefreshText;
|
||||
@property (copy, nonatomic) NSString *releaseToRefreshText;
|
||||
@property (copy, nonatomic) NSString *refreshingText;
|
||||
@end
|
||||
@@ -0,0 +1,242 @@
|
||||
//
|
||||
// MJRefreshBaseView.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 13-3-4.
|
||||
// Copyright (c) 2013年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshBaseView.h"
|
||||
#import "MJRefreshConst.h"
|
||||
#import "UIView+Extension.h"
|
||||
#import "UIScrollView+Extension.h"
|
||||
#import <objc/message.h>
|
||||
|
||||
@interface MJRefreshBaseView()
|
||||
{
|
||||
__weak UILabel *_statusLabel;
|
||||
__weak UIImageView *_arrowImage;
|
||||
__weak UIActivityIndicatorView *_activityView;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MJRefreshBaseView
|
||||
#pragma mark - 控件初始化
|
||||
/**
|
||||
* 状态标签
|
||||
*/
|
||||
- (UILabel *)statusLabel
|
||||
{
|
||||
if (!_statusLabel) {
|
||||
UILabel *statusLabel = [[UILabel alloc] init];
|
||||
statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
statusLabel.font = [UIFont boldSystemFontOfSize:13];
|
||||
statusLabel.textColor = MJRefreshLabelTextColor;
|
||||
statusLabel.backgroundColor = [UIColor clearColor];
|
||||
statusLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:_statusLabel = statusLabel];
|
||||
}
|
||||
return _statusLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 箭头图片
|
||||
*/
|
||||
- (UIImageView *)arrowImage
|
||||
{
|
||||
if (!_arrowImage) {
|
||||
UIImageView *arrowImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:MJRefreshSrcName(@"arrow.png")]];
|
||||
arrowImage.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
|
||||
[self addSubview:_arrowImage = arrowImage];
|
||||
}
|
||||
return _arrowImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态标签
|
||||
*/
|
||||
- (UIActivityIndicatorView *)activityView
|
||||
{
|
||||
if (!_activityView) {
|
||||
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
||||
activityView.bounds = self.arrowImage.bounds;
|
||||
activityView.autoresizingMask = self.arrowImage.autoresizingMask;
|
||||
[self addSubview:_activityView = activityView];
|
||||
}
|
||||
return _activityView;
|
||||
}
|
||||
|
||||
#pragma mark - 初始化方法
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
frame.size.height = MJRefreshViewHeight;
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
// 1.自己的属性
|
||||
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
// 2.设置默认状态
|
||||
self.state = MJRefreshStateNormal;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
// 1.箭头
|
||||
CGFloat arrowX = self.width * 0.5 - 100;
|
||||
self.arrowImage.center = CGPointMake(arrowX, self.height * 0.5);
|
||||
|
||||
// 2.指示器
|
||||
self.activityView.center = self.arrowImage.center;
|
||||
}
|
||||
|
||||
- (void)willMoveToSuperview:(UIView *)newSuperview
|
||||
{
|
||||
[super willMoveToSuperview:newSuperview];
|
||||
|
||||
// 旧的父控件
|
||||
[self.superview removeObserver:self forKeyPath:MJRefreshContentOffset context:nil];
|
||||
|
||||
if (newSuperview) { // 新的父控件
|
||||
[newSuperview addObserver:self forKeyPath:MJRefreshContentOffset options:NSKeyValueObservingOptionNew context:nil];
|
||||
|
||||
// 设置宽度
|
||||
self.width = newSuperview.width;
|
||||
// 设置位置
|
||||
self.x = 0;
|
||||
|
||||
// 记录UIScrollView
|
||||
_scrollView = (UIScrollView *)newSuperview;
|
||||
// 记录UIScrollView最开始的contentInset
|
||||
_scrollViewOriginalInset = _scrollView.contentInset;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 显示到屏幕上
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
if (self.state == MJRefreshStateWillRefreshing) {
|
||||
self.state = MJRefreshStateRefreshing;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 刷新相关
|
||||
#pragma mark 是否正在刷新
|
||||
- (BOOL)isRefreshing
|
||||
{
|
||||
return MJRefreshStateRefreshing == self.state;
|
||||
}
|
||||
|
||||
#pragma mark 开始刷新
|
||||
- (void)beginRefreshing
|
||||
{
|
||||
if (self.window) {
|
||||
self.state = MJRefreshStateRefreshing;
|
||||
} else {
|
||||
#warning 不能调用set方法
|
||||
_state = MJRefreshStateWillRefreshing;
|
||||
[super setNeedsDisplay];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark 结束刷新
|
||||
- (void)endRefreshing
|
||||
{
|
||||
double delayInSeconds = 0.3;
|
||||
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
||||
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
|
||||
self.state = MJRefreshStateNormal;
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - 设置状态
|
||||
- (void)setPullToRefreshText:(NSString *)pullToRefreshText
|
||||
{
|
||||
_pullToRefreshText = [pullToRefreshText copy];
|
||||
[self settingLabelText];
|
||||
}
|
||||
- (void)setReleaseToRefreshText:(NSString *)releaseToRefreshText
|
||||
{
|
||||
_releaseToRefreshText = [releaseToRefreshText copy];
|
||||
[self settingLabelText];
|
||||
}
|
||||
- (void)setRefreshingText:(NSString *)refreshingText
|
||||
{
|
||||
_refreshingText = [refreshingText copy];
|
||||
[self settingLabelText];
|
||||
}
|
||||
- (void)settingLabelText
|
||||
{
|
||||
switch (self.state) {
|
||||
case MJRefreshStateNormal:
|
||||
// 设置文字
|
||||
self.statusLabel.text = self.pullToRefreshText;
|
||||
break;
|
||||
case MJRefreshStatePulling:
|
||||
// 设置文字
|
||||
self.statusLabel.text = self.releaseToRefreshText;
|
||||
break;
|
||||
case MJRefreshStateRefreshing:
|
||||
// 设置文字
|
||||
self.statusLabel.text = self.refreshingText;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
// 0.存储当前的contentInset
|
||||
if (self.state != MJRefreshStateRefreshing) {
|
||||
_scrollViewOriginalInset = self.scrollView.contentInset;
|
||||
}
|
||||
|
||||
// 1.一样的就直接返回
|
||||
if (self.state == state) return;
|
||||
|
||||
// 2.根据状态执行不同的操作
|
||||
switch (state) {
|
||||
case MJRefreshStateNormal: // 普通状态
|
||||
{
|
||||
// 显示箭头
|
||||
self.arrowImage.hidden = NO;
|
||||
|
||||
// 停止转圈圈
|
||||
[self.activityView stopAnimating];
|
||||
break;
|
||||
}
|
||||
|
||||
case MJRefreshStatePulling:
|
||||
break;
|
||||
|
||||
case MJRefreshStateRefreshing:
|
||||
{
|
||||
// 开始转圈圈
|
||||
[self.activityView startAnimating];
|
||||
// 隐藏箭头
|
||||
self.arrowImage.hidden = YES;
|
||||
|
||||
// 回调
|
||||
if ([self.beginRefreshingTaget respondsToSelector:self.beginRefreshingAction]) {
|
||||
objc_msgSend(self.beginRefreshingTaget, self.beginRefreshingAction, self);
|
||||
}
|
||||
|
||||
if (self.beginRefreshingCallback) {
|
||||
self.beginRefreshingCallback();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 3.存储状态
|
||||
_state = state;
|
||||
|
||||
// 4.设置文字
|
||||
[self settingLabelText];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// MJRefreshConst.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 14-1-3.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#ifdef DEBUG
|
||||
#define MJLog(...) NSLog(__VA_ARGS__)
|
||||
#else
|
||||
#define MJLog(...)
|
||||
#endif
|
||||
|
||||
#define MJColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
|
||||
// 文字颜色
|
||||
#define MJRefreshLabelTextColor MJColor(150, 150, 150)
|
||||
|
||||
extern const CGFloat MJRefreshViewHeight;
|
||||
extern const CGFloat MJRefreshFastAnimationDuration;
|
||||
extern const CGFloat MJRefreshSlowAnimationDuration;
|
||||
|
||||
extern NSString *const MJRefreshBundleName;
|
||||
#define MJRefreshSrcName(file) [MJRefreshBundleName stringByAppendingPathComponent:file]
|
||||
|
||||
extern NSString *const MJRefreshFooterPullToRefresh;
|
||||
extern NSString *const MJRefreshFooterReleaseToRefresh;
|
||||
extern NSString *const MJRefreshFooterRefreshing;
|
||||
|
||||
extern NSString *const MJRefreshHeaderPullToRefresh;
|
||||
extern NSString *const MJRefreshHeaderReleaseToRefresh;
|
||||
extern NSString *const MJRefreshHeaderRefreshing;
|
||||
extern NSString *const MJRefreshHeaderTimeKey;
|
||||
|
||||
extern NSString *const MJRefreshContentOffset;
|
||||
extern NSString *const MJRefreshContentSize;
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MJRefreshConst.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 14-1-3.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
const CGFloat MJRefreshViewHeight = 44.0;
|
||||
const CGFloat MJRefreshFastAnimationDuration = 0.25;
|
||||
const CGFloat MJRefreshSlowAnimationDuration = 0.4;
|
||||
|
||||
NSString *const MJRefreshBundleName = @"MJRefresh.bundle";
|
||||
|
||||
NSString *const MJRefreshFooterPullToRefresh = @"上拉可以加载更多数据";
|
||||
NSString *const MJRefreshFooterReleaseToRefresh = @"松开立即加载更多数据";
|
||||
NSString *const MJRefreshFooterRefreshing = @"正在加载数据...";
|
||||
|
||||
NSString *const MJRefreshHeaderPullToRefresh = @"下拉可以刷新";
|
||||
NSString *const MJRefreshHeaderReleaseToRefresh = @"松开立即刷新";
|
||||
NSString *const MJRefreshHeaderRefreshing = @"正在刷新...";
|
||||
NSString *const MJRefreshHeaderTimeKey = @"MJRefreshHeaderView";
|
||||
|
||||
NSString *const MJRefreshContentOffset = @"contentOffset";
|
||||
NSString *const MJRefreshContentSize = @"contentSize";
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// MJRefreshTableFooterView.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 13-2-26.
|
||||
// Copyright (c) 2013年 itcast. All rights reserved.
|
||||
// 上拉加载更多
|
||||
|
||||
#import "MJRefreshBaseView.h"
|
||||
|
||||
@interface MJRefreshFooterView : MJRefreshBaseView
|
||||
+ (instancetype)footer;
|
||||
@end
|
||||
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// MJRefreshFooterView.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 13-2-26.
|
||||
// Copyright (c) 2013年 itcast. All rights reserved.
|
||||
// 上拉加载更多
|
||||
|
||||
#import "MJRefreshFooterView.h"
|
||||
#import "MJRefreshConst.h"
|
||||
#import "UIView+Extension.h"
|
||||
#import "UIScrollView+Extension.h"
|
||||
|
||||
@interface MJRefreshFooterView()
|
||||
@property (assign, nonatomic) int lastRefreshCount;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshFooterView
|
||||
|
||||
+ (instancetype)footer
|
||||
{
|
||||
return [[MJRefreshFooterView alloc] init];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.pullToRefreshText = MJRefreshFooterPullToRefresh;
|
||||
self.releaseToRefreshText = MJRefreshFooterReleaseToRefresh;
|
||||
self.refreshingText = MJRefreshFooterRefreshing;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
self.statusLabel.frame = self.bounds;
|
||||
}
|
||||
|
||||
- (void)willMoveToSuperview:(UIView *)newSuperview
|
||||
{
|
||||
[super willMoveToSuperview:newSuperview];
|
||||
|
||||
// 旧的父控件
|
||||
[self.superview removeObserver:self forKeyPath:MJRefreshContentSize context:nil];
|
||||
|
||||
if (newSuperview) { // 新的父控件
|
||||
// 监听
|
||||
[newSuperview addObserver:self forKeyPath:MJRefreshContentSize options:NSKeyValueObservingOptionNew context:nil];
|
||||
|
||||
// 重新调整frame
|
||||
[self adjustFrameWithContentSize];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark 重写调整frame
|
||||
- (void)adjustFrameWithContentSize
|
||||
{
|
||||
// 内容的高度
|
||||
CGFloat contentHeight = self.scrollView.contentSizeHeight;
|
||||
// 表格的高度
|
||||
CGFloat scrollHeight = self.scrollView.height - self.scrollViewOriginalInset.top - self.scrollViewOriginalInset.bottom;
|
||||
// 设置位置和尺寸
|
||||
self.y = MAX(contentHeight, scrollHeight);
|
||||
}
|
||||
|
||||
#pragma mark 监听UIScrollView的属性
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
// 不能跟用户交互,直接返回
|
||||
if (!self.userInteractionEnabled || self.alpha <= 0.01 || self.hidden) return;
|
||||
|
||||
if ([MJRefreshContentSize isEqualToString:keyPath]) {
|
||||
// 调整frame
|
||||
[self adjustFrameWithContentSize];
|
||||
} else if ([MJRefreshContentOffset isEqualToString:keyPath]) {
|
||||
#warning 这个返回一定要放这个位置
|
||||
// 如果正在刷新,直接返回
|
||||
if (self.state == MJRefreshStateRefreshing) return;
|
||||
|
||||
// 调整状态
|
||||
[self adjustStateWithContentOffset];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整状态
|
||||
*/
|
||||
- (void)adjustStateWithContentOffset
|
||||
{
|
||||
// 当前的contentOffset
|
||||
CGFloat currentOffsetY = self.scrollView.contentOffsetY;
|
||||
// 尾部控件刚好出现的offsetY
|
||||
CGFloat happenOffsetY = [self happenOffsetY];
|
||||
|
||||
// 如果是向下滚动到看不见尾部控件,直接返回
|
||||
if (currentOffsetY <= happenOffsetY) return;
|
||||
|
||||
if (self.scrollView.isDragging) {
|
||||
// 普通 和 即将刷新 的临界点
|
||||
CGFloat normal2pullingOffsetY = happenOffsetY + self.height;
|
||||
|
||||
if (self.state == MJRefreshStateNormal && currentOffsetY > normal2pullingOffsetY) {
|
||||
// 转为即将刷新状态
|
||||
self.state = MJRefreshStatePulling;
|
||||
} else if (self.state == MJRefreshStatePulling && currentOffsetY <= normal2pullingOffsetY) {
|
||||
// 转为普通状态
|
||||
self.state = MJRefreshStateNormal;
|
||||
}
|
||||
} else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开
|
||||
// 开始刷新
|
||||
self.state = MJRefreshStateRefreshing;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 状态相关
|
||||
#pragma mark 设置状态
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
// 1.一样的就直接返回
|
||||
if (self.state == state) return;
|
||||
|
||||
// 2.保存旧状态
|
||||
MJRefreshState oldState = self.state;
|
||||
|
||||
// 3.调用父类方法
|
||||
[super setState:state];
|
||||
|
||||
// 4.根据状态来设置属性
|
||||
switch (state)
|
||||
{
|
||||
case MJRefreshStateNormal:
|
||||
{
|
||||
// 刷新完毕
|
||||
if (MJRefreshStateRefreshing == oldState) {
|
||||
self.arrowImage.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
[UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{
|
||||
self.scrollView.contentInsetBottom = self.scrollViewOriginalInset.bottom;
|
||||
}];
|
||||
} else {
|
||||
// 执行动画
|
||||
[UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
|
||||
self.arrowImage.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
}];
|
||||
}
|
||||
|
||||
CGFloat deltaH = [self heightForContentBreakView];
|
||||
int currentCount = [self totalDataCountInScrollView];
|
||||
// 刚刷新完毕
|
||||
if (MJRefreshStateRefreshing == oldState && deltaH > 0 && currentCount != self.lastRefreshCount) {
|
||||
self.scrollView.contentOffsetY = self.scrollView.contentOffsetY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MJRefreshStatePulling:
|
||||
{
|
||||
[UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
|
||||
self.arrowImage.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
break;
|
||||
}
|
||||
|
||||
case MJRefreshStateRefreshing:
|
||||
{
|
||||
// 记录刷新前的数量
|
||||
self.lastRefreshCount = [self totalDataCountInScrollView];
|
||||
|
||||
[UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
|
||||
CGFloat bottom = self.height + self.scrollViewOriginalInset.bottom;
|
||||
CGFloat deltaH = [self heightForContentBreakView];
|
||||
if (deltaH < 0) { // 如果内容高度小于view的高度
|
||||
bottom -= deltaH;
|
||||
}
|
||||
self.scrollView.contentInsetBottom = bottom;
|
||||
}];
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (int)totalDataCountInScrollView
|
||||
{
|
||||
int totalCount = 0;
|
||||
if ([self.scrollView isKindOfClass:[UITableView class]]) {
|
||||
UITableView *tableView = (UITableView *)self.scrollView;
|
||||
|
||||
for (int section = 0; section<tableView.numberOfSections; section++) {
|
||||
totalCount += [tableView numberOfRowsInSection:section];
|
||||
}
|
||||
} else if ([self.scrollView isKindOfClass:[UICollectionView class]]) {
|
||||
UICollectionView *collectionView = (UICollectionView *)self.scrollView;
|
||||
|
||||
for (int section = 0; section<collectionView.numberOfSections; section++) {
|
||||
totalCount += [collectionView numberOfItemsInSection:section];
|
||||
}
|
||||
}
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
#pragma mark 获得scrollView的内容 超出 view 的高度
|
||||
- (CGFloat)heightForContentBreakView
|
||||
{
|
||||
CGFloat h = self.scrollView.frame.size.height - self.scrollViewOriginalInset.bottom - self.scrollViewOriginalInset.top;
|
||||
return self.scrollView.contentSize.height - h;
|
||||
}
|
||||
|
||||
#pragma mark - 在父类中用得上
|
||||
/**
|
||||
* 刚好看到上拉刷新控件时的contentOffset.y
|
||||
*/
|
||||
- (CGFloat)happenOffsetY
|
||||
{
|
||||
CGFloat deltaH = [self heightForContentBreakView];
|
||||
if (deltaH > 0) {
|
||||
return deltaH - self.scrollViewOriginalInset.top;
|
||||
} else {
|
||||
return - self.scrollViewOriginalInset.top;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// MJRefreshHeaderView.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 13-2-26.
|
||||
// Copyright (c) 2013年 itcast. All rights reserved.
|
||||
// 下拉刷新
|
||||
|
||||
#import "MJRefreshBaseView.h"
|
||||
|
||||
@interface MJRefreshHeaderView : MJRefreshBaseView
|
||||
+ (instancetype)header;
|
||||
@end
|
||||
@@ -0,0 +1,230 @@
|
||||
//
|
||||
// MJRefreshHeaderView.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by mj on 13-2-26.
|
||||
// Copyright (c) 2013年 itcast. All rights reserved.
|
||||
// 下拉刷新
|
||||
|
||||
#import "MJRefreshConst.h"
|
||||
#import "MJRefreshHeaderView.h"
|
||||
#import "UIView+Extension.h"
|
||||
#import "UIScrollView+Extension.h"
|
||||
|
||||
@interface MJRefreshHeaderView()
|
||||
// 最后的更新时间
|
||||
@property (nonatomic, strong) NSDate *lastUpdateTime;
|
||||
@property (nonatomic, weak) UILabel *lastUpdateTimeLabel;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshHeaderView
|
||||
#pragma mark - 控件初始化
|
||||
/**
|
||||
* 时间标签
|
||||
*/
|
||||
- (UILabel *)lastUpdateTimeLabel
|
||||
{
|
||||
if (!_lastUpdateTimeLabel) {
|
||||
// 1.创建控件
|
||||
UILabel *lastUpdateTimeLabel = [[UILabel alloc] init];
|
||||
lastUpdateTimeLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
lastUpdateTimeLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
lastUpdateTimeLabel.textColor = MJRefreshLabelTextColor;
|
||||
lastUpdateTimeLabel.backgroundColor = [UIColor clearColor];
|
||||
lastUpdateTimeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:_lastUpdateTimeLabel = lastUpdateTimeLabel];
|
||||
|
||||
// 2.加载时间
|
||||
self.lastUpdateTime = [[NSUserDefaults standardUserDefaults] objectForKey:MJRefreshHeaderTimeKey];
|
||||
}
|
||||
return _lastUpdateTimeLabel;
|
||||
}
|
||||
|
||||
+ (instancetype)header
|
||||
{
|
||||
return [[MJRefreshHeaderView alloc] init];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.pullToRefreshText = MJRefreshHeaderPullToRefresh;
|
||||
self.releaseToRefreshText = MJRefreshHeaderReleaseToRefresh;
|
||||
self.refreshingText = MJRefreshHeaderRefreshing;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
CGFloat statusX = 0;
|
||||
CGFloat statusY = 0;
|
||||
CGFloat statusHeight = self.height * 0.5;
|
||||
CGFloat statusWidth = self.width;
|
||||
// 1.状态标签
|
||||
self.statusLabel.frame = CGRectMake(statusX, statusY, statusWidth, statusHeight);
|
||||
|
||||
// 2.时间标签
|
||||
CGFloat lastUpdateY = statusHeight;
|
||||
CGFloat lastUpdateX = 0;
|
||||
CGFloat lastUpdateHeight = statusHeight;
|
||||
CGFloat lastUpdateWidth = statusWidth;
|
||||
self.lastUpdateTimeLabel.frame = CGRectMake(lastUpdateX, lastUpdateY, lastUpdateWidth, lastUpdateHeight);
|
||||
}
|
||||
|
||||
- (void)willMoveToSuperview:(UIView *)newSuperview
|
||||
{
|
||||
[super willMoveToSuperview:newSuperview];
|
||||
|
||||
// 设置自己的位置和尺寸
|
||||
self.y = - self.height;
|
||||
}
|
||||
|
||||
#pragma mark - 状态相关
|
||||
#pragma mark 设置最后的更新时间
|
||||
- (void)setLastUpdateTime:(NSDate *)lastUpdateTime
|
||||
{
|
||||
_lastUpdateTime = lastUpdateTime;
|
||||
|
||||
// 1.归档
|
||||
[[NSUserDefaults standardUserDefaults] setObject:lastUpdateTime forKey:MJRefreshHeaderTimeKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
// 2.更新时间
|
||||
[self updateTimeLabel];
|
||||
}
|
||||
|
||||
#pragma mark 更新时间字符串
|
||||
- (void)updateTimeLabel
|
||||
{
|
||||
if (!self.lastUpdateTime) return;
|
||||
|
||||
// 1.获得年月日
|
||||
NSCalendar *calendar = [NSCalendar currentCalendar];
|
||||
NSUInteger unitFlags = NSYearCalendarUnit| NSMonthCalendarUnit | NSDayCalendarUnit |NSHourCalendarUnit |NSMinuteCalendarUnit;
|
||||
NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:_lastUpdateTime];
|
||||
NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]];
|
||||
|
||||
// 2.格式化日期
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
if ([cmp1 day] == [cmp2 day]) { // 今天
|
||||
formatter.dateFormat = @"今天 HH:mm";
|
||||
} else if ([cmp1 year] == [cmp2 year]) { // 今年
|
||||
formatter.dateFormat = @"MM-dd HH:mm";
|
||||
} else {
|
||||
formatter.dateFormat = @"yyyy-MM-dd HH:mm";
|
||||
}
|
||||
NSString *time = [formatter stringFromDate:self.lastUpdateTime];
|
||||
|
||||
// 3.显示日期
|
||||
self.lastUpdateTimeLabel.text = [NSString stringWithFormat:@"最后更新:%@", time];
|
||||
}
|
||||
|
||||
#pragma mark - 监听UIScrollView的contentOffset属性
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
// 不能跟用户交互就直接返回
|
||||
if (!self.userInteractionEnabled || self.alpha <= 0.01 || self.hidden) return;
|
||||
|
||||
// 如果正在刷新,直接返回
|
||||
if (self.state == MJRefreshStateRefreshing) return;
|
||||
|
||||
if ([MJRefreshContentOffset isEqualToString:keyPath]) {
|
||||
[self adjustStateWithContentOffset];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整状态
|
||||
*/
|
||||
- (void)adjustStateWithContentOffset
|
||||
{
|
||||
// 当前的contentOffset
|
||||
CGFloat currentOffsetY = self.scrollView.contentOffsetY;
|
||||
// 头部控件刚好出现的offsetY
|
||||
CGFloat happenOffsetY = - self.scrollViewOriginalInset.top;
|
||||
|
||||
// 如果是向上滚动到看不见头部控件,直接返回
|
||||
if (currentOffsetY >= happenOffsetY) return;
|
||||
|
||||
if (self.scrollView.isDragging) {
|
||||
// 普通 和 即将刷新 的临界点
|
||||
CGFloat normal2pullingOffsetY = happenOffsetY - self.height;
|
||||
|
||||
if (self.state == MJRefreshStateNormal && currentOffsetY < normal2pullingOffsetY) {
|
||||
// 转为即将刷新状态
|
||||
self.state = MJRefreshStatePulling;
|
||||
} else if (self.state == MJRefreshStatePulling && currentOffsetY >= normal2pullingOffsetY) {
|
||||
// 转为普通状态
|
||||
self.state = MJRefreshStateNormal;
|
||||
}
|
||||
} else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开
|
||||
// 开始刷新
|
||||
self.state = MJRefreshStateRefreshing;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark 设置状态
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
// 1.一样的就直接返回
|
||||
if (self.state == state) return;
|
||||
|
||||
// 2.保存旧状态
|
||||
MJRefreshState oldState = self.state;
|
||||
|
||||
// 3.调用父类方法
|
||||
[super setState:state];
|
||||
|
||||
// 4.根据状态执行不同的操作
|
||||
switch (state) {
|
||||
case MJRefreshStateNormal: // 下拉可以刷新
|
||||
{
|
||||
// 刷新完毕
|
||||
if (MJRefreshStateRefreshing == oldState) {
|
||||
self.arrowImage.transform = CGAffineTransformIdentity;
|
||||
// 保存刷新时间
|
||||
self.lastUpdateTime = [NSDate date];
|
||||
|
||||
[UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{
|
||||
self.scrollView.contentInsetTop = self.scrollViewOriginalInset.top;
|
||||
}];
|
||||
} else {
|
||||
// 执行动画
|
||||
[UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
|
||||
self.arrowImage.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MJRefreshStatePulling: // 松开可立即刷新
|
||||
{
|
||||
// 执行动画
|
||||
[UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
|
||||
self.arrowImage.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
}];
|
||||
break;
|
||||
}
|
||||
|
||||
case MJRefreshStateRefreshing: // 正在刷新中
|
||||
{
|
||||
// 执行动画
|
||||
[UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
|
||||
// 1.增加滚动区域
|
||||
CGFloat top = self.scrollViewOriginalInset.top + self.height;
|
||||
self.scrollView.contentInsetTop = top;
|
||||
|
||||
// 2.设置滚动位置
|
||||
self.scrollView.contentOffsetY = - top;
|
||||
}];
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// UIScrollView+Extension.h
|
||||
// MJRefreshExample
|
||||
//
|
||||
// Created by MJ Lee on 14-5-28.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIScrollView (Extension)
|
||||
@property (assign, nonatomic) CGFloat contentInsetTop;
|
||||
@property (assign, nonatomic) CGFloat contentInsetBottom;
|
||||
@property (assign, nonatomic) CGFloat contentInsetLeft;
|
||||
@property (assign, nonatomic) CGFloat contentInsetRight;
|
||||
|
||||
@property (assign, nonatomic) CGFloat contentOffsetX;
|
||||
@property (assign, nonatomic) CGFloat contentOffsetY;
|
||||
|
||||
@property (assign, nonatomic) CGFloat contentSizeWidth;
|
||||
@property (assign, nonatomic) CGFloat contentSizeHeight;
|
||||
@end
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// UIScrollView+Extension.m
|
||||
// MJRefreshExample
|
||||
//
|
||||
// Created by MJ Lee on 14-5-28.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIScrollView+Extension.h"
|
||||
|
||||
@implementation UIScrollView (Extension)
|
||||
- (void)setContentInsetTop:(CGFloat)contentInsetTop
|
||||
{
|
||||
UIEdgeInsets inset = self.contentInset;
|
||||
inset.top = contentInsetTop;
|
||||
self.contentInset = inset;
|
||||
}
|
||||
|
||||
- (CGFloat)contentInsetTop
|
||||
{
|
||||
return self.contentInset.top;
|
||||
}
|
||||
|
||||
- (void)setContentInsetBottom:(CGFloat)contentInsetBottom
|
||||
{
|
||||
UIEdgeInsets inset = self.contentInset;
|
||||
inset.bottom = contentInsetBottom;
|
||||
self.contentInset = inset;
|
||||
}
|
||||
|
||||
- (CGFloat)contentInsetBottom
|
||||
{
|
||||
return self.contentInset.bottom;
|
||||
}
|
||||
|
||||
- (void)setContentInsetLeft:(CGFloat)contentInsetLeft
|
||||
{
|
||||
UIEdgeInsets inset = self.contentInset;
|
||||
inset.left = contentInsetLeft;
|
||||
self.contentInset = inset;
|
||||
}
|
||||
|
||||
- (CGFloat)contentInsetLeft
|
||||
{
|
||||
return self.contentInset.left;
|
||||
}
|
||||
|
||||
- (void)setContentInsetRight:(CGFloat)contentInsetRight
|
||||
{
|
||||
UIEdgeInsets inset = self.contentInset;
|
||||
inset.right = contentInsetRight;
|
||||
self.contentInset = inset;
|
||||
}
|
||||
|
||||
- (CGFloat)contentInsetRight
|
||||
{
|
||||
return self.contentInset.right;
|
||||
}
|
||||
|
||||
- (void)setContentOffsetX:(CGFloat)contentOffsetX
|
||||
{
|
||||
CGPoint offset = self.contentOffset;
|
||||
offset.x = contentOffsetX;
|
||||
self.contentOffset = offset;
|
||||
}
|
||||
|
||||
- (CGFloat)contentOffsetX
|
||||
{
|
||||
return self.contentOffset.x;
|
||||
}
|
||||
|
||||
- (void)setContentOffsetY:(CGFloat)contentOffsetY
|
||||
{
|
||||
CGPoint offset = self.contentOffset;
|
||||
offset.y = contentOffsetY;
|
||||
self.contentOffset = offset;
|
||||
}
|
||||
|
||||
- (CGFloat)contentOffsetY
|
||||
{
|
||||
return self.contentOffset.y;
|
||||
}
|
||||
|
||||
- (void)setContentSizeWidth:(CGFloat)contentSizeWidth
|
||||
{
|
||||
CGSize size = self.contentSize;
|
||||
size.width = contentSizeWidth;
|
||||
self.contentSize = size;
|
||||
}
|
||||
|
||||
- (CGFloat)contentSizeWidth
|
||||
{
|
||||
return self.contentSize.width;
|
||||
}
|
||||
|
||||
- (void)setContentSizeHeight:(CGFloat)contentSizeHeight
|
||||
{
|
||||
CGSize size = self.contentSize;
|
||||
size.height = contentSizeHeight;
|
||||
self.contentSize = size;
|
||||
}
|
||||
|
||||
- (CGFloat)contentSizeHeight
|
||||
{
|
||||
return self.contentSize.height;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// UIScrollView+MJRefresh.h
|
||||
// MJRefreshExample
|
||||
//
|
||||
// Created by MJ Lee on 14-5-28.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIScrollView (MJRefresh)
|
||||
#pragma mark - 下拉刷新
|
||||
/**
|
||||
* 添加一个下拉刷新头部控件
|
||||
*
|
||||
* @param callback 回调
|
||||
*/
|
||||
- (void)addHeaderWithCallback:(void (^)())callback;
|
||||
|
||||
/**
|
||||
* 添加一个下拉刷新头部控件
|
||||
*
|
||||
* @param target 目标
|
||||
* @param action 回调方法
|
||||
*/
|
||||
- (void)addHeaderWithTarget:(id)target action:(SEL)action;
|
||||
|
||||
/**
|
||||
* 移除下拉刷新头部控件
|
||||
*/
|
||||
- (void)removeHeader;
|
||||
|
||||
/**
|
||||
* 主动让下拉刷新头部控件进入刷新状态
|
||||
*/
|
||||
- (void)headerBeginRefreshing;
|
||||
|
||||
/**
|
||||
* 让下拉刷新头部控件停止刷新状态
|
||||
*/
|
||||
- (void)headerEndRefreshing;
|
||||
|
||||
/**
|
||||
* 下拉刷新头部控件的可见性
|
||||
*/
|
||||
@property (nonatomic, assign, getter = isHeaderHidden) BOOL headerHidden;
|
||||
|
||||
#pragma mark - 上拉刷新
|
||||
/**
|
||||
* 添加一个上拉刷新尾部控件
|
||||
*
|
||||
* @param callback 回调
|
||||
*/
|
||||
- (void)addFooterWithCallback:(void (^)())callback;
|
||||
|
||||
/**
|
||||
* 添加一个上拉刷新尾部控件
|
||||
*
|
||||
* @param target 目标
|
||||
* @param action 回调方法
|
||||
*/
|
||||
- (void)addFooterWithTarget:(id)target action:(SEL)action;
|
||||
|
||||
/**
|
||||
* 移除上拉刷新尾部控件
|
||||
*/
|
||||
- (void)removeFooter;
|
||||
|
||||
/**
|
||||
* 主动让上拉刷新尾部控件进入刷新状态
|
||||
*/
|
||||
- (void)footerBeginRefreshing;
|
||||
|
||||
/**
|
||||
* 让上拉刷新尾部控件停止刷新状态
|
||||
*/
|
||||
- (void)footerEndRefreshing;
|
||||
|
||||
/**
|
||||
* 下拉刷新头部控件的可见性
|
||||
*/
|
||||
@property (nonatomic, assign, getter = isFooterHidden) BOOL footerHidden;
|
||||
|
||||
/**
|
||||
* 设置尾部控件的文字
|
||||
*/
|
||||
@property (copy, nonatomic) NSString *footerPullToRefreshText; // 默认:@"上拉可以加载更多数据"
|
||||
@property (copy, nonatomic) NSString *footerReleaseToRefreshText; // 默认:@"松开立即加载更多数据"
|
||||
@property (copy, nonatomic) NSString *footerRefreshingText; // 默认:@"MJ哥正在帮你加载数据..."
|
||||
|
||||
/**
|
||||
* 设置头部控件的文字
|
||||
*/
|
||||
@property (copy, nonatomic) NSString *headerPullToRefreshText; // 默认:@"下拉可以刷新"
|
||||
@property (copy, nonatomic) NSString *headerReleaseToRefreshText; // 默认:@"松开立即刷新"
|
||||
@property (copy, nonatomic) NSString *headerRefreshingText; // 默认:@"MJ哥正在帮你刷新..."
|
||||
@end
|
||||
@@ -0,0 +1,266 @@
|
||||
//
|
||||
// UIScrollView+MJRefresh.m
|
||||
// MJRefreshExample
|
||||
//
|
||||
// Created by MJ Lee on 14-5-28.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIScrollView+MJRefresh.h"
|
||||
#import "MJRefreshHeaderView.h"
|
||||
#import "MJRefreshFooterView.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@interface UIScrollView()
|
||||
@property (weak, nonatomic) MJRefreshHeaderView *header;
|
||||
@property (weak, nonatomic) MJRefreshFooterView *footer;
|
||||
@end
|
||||
|
||||
|
||||
@implementation UIScrollView (MJRefresh)
|
||||
|
||||
#pragma mark - 运行时相关
|
||||
static char MJRefreshHeaderViewKey;
|
||||
static char MJRefreshFooterViewKey;
|
||||
|
||||
- (void)setHeader:(MJRefreshHeaderView *)header {
|
||||
[self willChangeValueForKey:@"MJRefreshHeaderViewKey"];
|
||||
objc_setAssociatedObject(self, &MJRefreshHeaderViewKey,
|
||||
header,
|
||||
OBJC_ASSOCIATION_ASSIGN);
|
||||
[self didChangeValueForKey:@"MJRefreshHeaderViewKey"];
|
||||
}
|
||||
|
||||
- (MJRefreshHeaderView *)header {
|
||||
return objc_getAssociatedObject(self, &MJRefreshHeaderViewKey);
|
||||
}
|
||||
|
||||
- (void)setFooter:(MJRefreshFooterView *)footer {
|
||||
[self willChangeValueForKey:@"MJRefreshFooterViewKey"];
|
||||
objc_setAssociatedObject(self, &MJRefreshFooterViewKey,
|
||||
footer,
|
||||
OBJC_ASSOCIATION_ASSIGN);
|
||||
[self didChangeValueForKey:@"MJRefreshFooterViewKey"];
|
||||
}
|
||||
|
||||
- (MJRefreshFooterView *)footer {
|
||||
return objc_getAssociatedObject(self, &MJRefreshFooterViewKey);
|
||||
}
|
||||
|
||||
#pragma mark - 下拉刷新
|
||||
/**
|
||||
* 添加一个下拉刷新头部控件
|
||||
*
|
||||
* @param callback 回调
|
||||
*/
|
||||
- (void)addHeaderWithCallback:(void (^)())callback
|
||||
{
|
||||
// 1.创建新的header
|
||||
if (!self.header) {
|
||||
MJRefreshHeaderView *header = [MJRefreshHeaderView header];
|
||||
[self addSubview:header];
|
||||
self.header = header;
|
||||
}
|
||||
|
||||
// 2.设置block回调
|
||||
self.header.beginRefreshingCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个下拉刷新头部控件
|
||||
*
|
||||
* @param target 目标
|
||||
* @param action 回调方法
|
||||
*/
|
||||
- (void)addHeaderWithTarget:(id)target action:(SEL)action
|
||||
{
|
||||
// 1.创建新的header
|
||||
if (!self.header) {
|
||||
MJRefreshHeaderView *header = [MJRefreshHeaderView header];
|
||||
[self addSubview:header];
|
||||
self.header = header;
|
||||
}
|
||||
|
||||
// 2.设置目标和回调方法
|
||||
self.header.beginRefreshingTaget = target;
|
||||
self.header.beginRefreshingAction = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除下拉刷新头部控件
|
||||
*/
|
||||
- (void)removeHeader
|
||||
{
|
||||
[self.header removeFromSuperview];
|
||||
self.header = nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动让下拉刷新头部控件进入刷新状态
|
||||
*/
|
||||
- (void)headerBeginRefreshing
|
||||
{
|
||||
[self.header beginRefreshing];
|
||||
}
|
||||
|
||||
/**
|
||||
* 让下拉刷新头部控件停止刷新状态
|
||||
*/
|
||||
- (void)headerEndRefreshing
|
||||
{
|
||||
[self.header endRefreshing];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉刷新头部控件的可见性
|
||||
*/
|
||||
- (void)setHeaderHidden:(BOOL)hidden
|
||||
{
|
||||
self.header.hidden = hidden;
|
||||
}
|
||||
|
||||
- (BOOL)isHeaderHidden
|
||||
{
|
||||
return self.header.isHidden;
|
||||
}
|
||||
|
||||
#pragma mark - 上拉刷新
|
||||
/**
|
||||
* 添加一个上拉刷新尾部控件
|
||||
*
|
||||
* @param callback 回调
|
||||
*/
|
||||
- (void)addFooterWithCallback:(void (^)())callback
|
||||
{
|
||||
// 1.创建新的footer
|
||||
if (!self.footer) {
|
||||
MJRefreshFooterView *footer = [MJRefreshFooterView footer];
|
||||
[self addSubview:footer];
|
||||
self.footer = footer;
|
||||
}
|
||||
|
||||
// 2.设置block回调
|
||||
self.footer.beginRefreshingCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个上拉刷新尾部控件
|
||||
*
|
||||
* @param target 目标
|
||||
* @param action 回调方法
|
||||
*/
|
||||
- (void)addFooterWithTarget:(id)target action:(SEL)action
|
||||
{
|
||||
// 1.创建新的footer
|
||||
if (!self.footer) {
|
||||
MJRefreshFooterView *footer = [MJRefreshFooterView footer];
|
||||
[self addSubview:footer];
|
||||
self.footer = footer;
|
||||
}
|
||||
|
||||
// 2.设置目标和回调方法
|
||||
self.footer.beginRefreshingTaget = target;
|
||||
self.footer.beginRefreshingAction = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除上拉刷新尾部控件
|
||||
*/
|
||||
- (void)removeFooter
|
||||
{
|
||||
[self.footer removeFromSuperview];
|
||||
self.footer = nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动让上拉刷新尾部控件进入刷新状态
|
||||
*/
|
||||
- (void)footerBeginRefreshing
|
||||
{
|
||||
[self.footer beginRefreshing];
|
||||
}
|
||||
|
||||
/**
|
||||
* 让上拉刷新尾部控件停止刷新状态
|
||||
*/
|
||||
- (void)footerEndRefreshing
|
||||
{
|
||||
[self.footer endRefreshing];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉刷新头部控件的可见性
|
||||
*/
|
||||
- (void)setFooterHidden:(BOOL)hidden
|
||||
{
|
||||
self.footer.hidden = hidden;
|
||||
}
|
||||
|
||||
- (BOOL)isFooterHidden
|
||||
{
|
||||
return self.footer.isHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字
|
||||
*/
|
||||
- (void)setFooterPullToRefreshText:(NSString *)footerPullToRefreshText
|
||||
{
|
||||
self.footer.pullToRefreshText = footerPullToRefreshText;
|
||||
}
|
||||
|
||||
- (NSString *)footerPullToRefreshText
|
||||
{
|
||||
return self.footer.pullToRefreshText;
|
||||
}
|
||||
|
||||
- (void)setFooterReleaseToRefreshText:(NSString *)footerReleaseToRefreshText
|
||||
{
|
||||
self.footer.releaseToRefreshText = footerReleaseToRefreshText;
|
||||
}
|
||||
|
||||
- (NSString *)footerReleaseToRefreshText
|
||||
{
|
||||
return self.footer.releaseToRefreshText;
|
||||
}
|
||||
|
||||
- (void)setFooterRefreshingText:(NSString *)footerRefreshingText
|
||||
{
|
||||
self.footer.refreshingText = footerRefreshingText;
|
||||
}
|
||||
|
||||
- (NSString *)footerRefreshingText
|
||||
{
|
||||
return self.footer.refreshingText;
|
||||
}
|
||||
|
||||
- (void)setHeaderPullToRefreshText:(NSString *)headerPullToRefreshText
|
||||
{
|
||||
self.header.pullToRefreshText = headerPullToRefreshText;
|
||||
}
|
||||
|
||||
- (NSString *)headerPullToRefreshText
|
||||
{
|
||||
return self.header.pullToRefreshText;
|
||||
}
|
||||
|
||||
- (void)setHeaderReleaseToRefreshText:(NSString *)headerReleaseToRefreshText
|
||||
{
|
||||
self.header.releaseToRefreshText = headerReleaseToRefreshText;
|
||||
}
|
||||
|
||||
- (NSString *)headerReleaseToRefreshText
|
||||
{
|
||||
return self.header.releaseToRefreshText;
|
||||
}
|
||||
|
||||
- (void)setHeaderRefreshingText:(NSString *)headerRefreshingText
|
||||
{
|
||||
self.header.refreshingText = headerRefreshingText;
|
||||
}
|
||||
|
||||
- (NSString *)headerRefreshingText
|
||||
{
|
||||
return self.header.refreshingText;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// UIView+Extension.h
|
||||
// MJRefreshExample
|
||||
//
|
||||
// Created by MJ Lee on 14-5-28.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIView (Extension)
|
||||
@property (assign, nonatomic) CGFloat x;
|
||||
@property (assign, nonatomic) CGFloat y;
|
||||
@property (assign, nonatomic) CGFloat width;
|
||||
@property (assign, nonatomic) CGFloat height;
|
||||
@property (assign, nonatomic) CGSize size;
|
||||
@property (assign, nonatomic) CGPoint origin;
|
||||
@end
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// UIView+Extension.m
|
||||
// MJRefreshExample
|
||||
//
|
||||
// Created by MJ Lee on 14-5-28.
|
||||
// Copyright (c) 2014年 itcast. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIView+Extension.h"
|
||||
|
||||
@implementation UIView (Extension)
|
||||
- (void)setX:(CGFloat)x
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
frame.origin.x = x;
|
||||
self.frame = frame;
|
||||
}
|
||||
|
||||
- (CGFloat)x
|
||||
{
|
||||
return self.frame.origin.x;
|
||||
}
|
||||
|
||||
- (void)setY:(CGFloat)y
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
frame.origin.y = y;
|
||||
self.frame = frame;
|
||||
}
|
||||
|
||||
- (CGFloat)y
|
||||
{
|
||||
return self.frame.origin.y;
|
||||
}
|
||||
|
||||
- (void)setWidth:(CGFloat)width
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
frame.size.width = width;
|
||||
self.frame = frame;
|
||||
}
|
||||
|
||||
- (CGFloat)width
|
||||
{
|
||||
return self.frame.size.width;
|
||||
}
|
||||
|
||||
- (void)setHeight:(CGFloat)height
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
frame.size.height = height;
|
||||
self.frame = frame;
|
||||
}
|
||||
|
||||
- (CGFloat)height
|
||||
{
|
||||
return self.frame.size.height;
|
||||
}
|
||||
|
||||
- (void)setSize:(CGSize)size
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
frame.size = size;
|
||||
self.frame = frame;
|
||||
}
|
||||
|
||||
- (CGSize)size
|
||||
{
|
||||
return self.frame.size;
|
||||
}
|
||||
|
||||
- (void)setOrigin:(CGPoint)origin
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
frame.origin = origin;
|
||||
self.frame = frame;
|
||||
}
|
||||
|
||||
- (CGPoint)origin
|
||||
{
|
||||
return self.frame.origin;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// ManagerConstants.h
|
||||
// ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 14-8-8.
|
||||
// Copyright (c) 2014年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ManagerDemo_ManagerConstants_h
|
||||
#define ManagerDemo_ManagerConstants_h
|
||||
|
||||
/**
|
||||
* 系统版本
|
||||
*/
|
||||
#define IOS_VERSION ( [[UIDevice currentDevice].systemVersion floatValue] )
|
||||
/**
|
||||
* 获取当前window宽高
|
||||
*/
|
||||
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width
|
||||
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// HomeAdView.h
|
||||
// ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 14-8-8.
|
||||
// Copyright (c) 2014年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ImagePlayerView.h"
|
||||
@interface HomeAdView : UIView<ImagePlayerViewDelegate>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// HomeAdView.m
|
||||
// ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 14-8-8.
|
||||
// Copyright (c) 2014年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HomeAdView.h"
|
||||
|
||||
@implementation HomeAdView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
ImagePlayerView* imagePlayerView = [[ImagePlayerView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
|
||||
imagePlayerView.autoScroll = YES;
|
||||
imagePlayerView.scrollInterval = 5;
|
||||
[imagePlayerView setPageControlPosition:ICPageControlPosition_BottomCenter];
|
||||
[imagePlayerView initWithCount:3 delegate:self];
|
||||
[self addSubview:imagePlayerView];
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
#pragma mark ImagePlayerViewDelegate
|
||||
-(void)imagePlayerView:(ImagePlayerView *)imagePlayerView loadImageForImageView:(UIImageView *)imageView index:(NSInteger)index{
|
||||
|
||||
[imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"ad%ld",index+1]]];
|
||||
}
|
||||
-(void)imagePlayerView:(ImagePlayerView *)imagePlayerView didTapAtIndex:(NSInteger)index{
|
||||
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// ImagePlayerView.h
|
||||
// ImagePlayerView
|
||||
//
|
||||
// Created by 陈颜俊 on 14-6-5.
|
||||
// Copyright (c) 2014年 Chenyanjun. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, ICPageControlPosition) {
|
||||
ICPageControlPosition_TopLeft,
|
||||
ICPageControlPosition_TopCenter,
|
||||
ICPageControlPosition_TopRight,
|
||||
ICPageControlPosition_BottomLeft,
|
||||
ICPageControlPosition_BottomCenter,
|
||||
ICPageControlPosition_BottomRight
|
||||
};
|
||||
|
||||
@protocol ImagePlayerViewDelegate;
|
||||
|
||||
@interface ImagePlayerView : UIView
|
||||
@property (nonatomic, assign) id<ImagePlayerViewDelegate> imagePlayerViewDelegate;
|
||||
@property (nonatomic, assign) BOOL autoScroll; // default is YES, set NO to turn off autoScroll
|
||||
@property (nonatomic, assign) NSUInteger scrollInterval; // scroll interval, unit: second, default is 2 seconds
|
||||
@property (nonatomic, assign) ICPageControlPosition pageControlPosition; // pageControl position, defautl is bottomright
|
||||
@property (nonatomic, assign) BOOL hidePageControl; // hide pageControl, default is NO
|
||||
|
||||
/**
|
||||
* Init image player
|
||||
*
|
||||
* @param imageURLs NSURL array, image path
|
||||
* @param placeholder placeholder image
|
||||
* @param delegate delegate
|
||||
* @deprecated use - (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate instead
|
||||
*/
|
||||
- (void)initWithImageURLs:(NSArray *)imageURLs placeholder:(UIImage *)placeholder delegate:(id<ImagePlayerViewDelegate>)delegate DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Init image player
|
||||
*
|
||||
* @param imageURLs NSURL array, image path
|
||||
* @param placeholder placeholder image
|
||||
* @param delegate delegate
|
||||
* @param edgeInsets scroll view edgeInsets
|
||||
* @deprecated use - (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate edgeInsets:(UIEdgeInsets)edgeInsets instead
|
||||
*/
|
||||
- (void)initWithImageURLs:(NSArray *)imageURLs placeholder:(UIImage *)placeholder delegate:(id<ImagePlayerViewDelegate>)delegate edgeInsets:(UIEdgeInsets)edgeInsets DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Init image player
|
||||
*
|
||||
* @param count
|
||||
* @param delegate
|
||||
*/
|
||||
- (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate;
|
||||
|
||||
/**
|
||||
* Init image player
|
||||
*
|
||||
* @param count
|
||||
* @param delegate
|
||||
* @param edgeInsets scroll view edgeInsets
|
||||
*/
|
||||
- (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate edgeInsets:(UIEdgeInsets)edgeInsets;
|
||||
@end
|
||||
|
||||
@protocol ImagePlayerViewDelegate <NSObject>
|
||||
|
||||
@required
|
||||
/**
|
||||
* Init imageview
|
||||
*
|
||||
* @param imagePlayerView ImagePlayerView object
|
||||
* @param imageView UIImageView object
|
||||
* @param index index of imageview
|
||||
*/
|
||||
- (void)imagePlayerView:(ImagePlayerView *)imagePlayerView loadImageForImageView:(UIImageView *)imageView index:(NSInteger)index;
|
||||
|
||||
@optional
|
||||
/**
|
||||
* Tap ImageView action
|
||||
*
|
||||
* @param imagePlayerView ImagePlayerView object
|
||||
* @param index index of imageview
|
||||
* @param imageURL image url
|
||||
* @deprecated use - (void)imagePlayerView:(ImagePlayerView *)imagePlayerView didTapAtIndex:(NSInteger)index instead
|
||||
*/
|
||||
- (void)imagePlayerView:(ImagePlayerView *)imagePlayerView didTapAtIndex:(NSInteger)index imageURL:(NSURL *)imageURL DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Tap ImageView action
|
||||
*
|
||||
* @param imagePlayerView ImagePlayerView object
|
||||
* @param index index of imageview
|
||||
*/
|
||||
- (void)imagePlayerView:(ImagePlayerView *)imagePlayerView didTapAtIndex:(NSInteger)index;
|
||||
@end
|
||||
@@ -0,0 +1,348 @@
|
||||
//
|
||||
// ImagePlayerView.m
|
||||
// ImagePlayerView
|
||||
//
|
||||
// Created by 陈颜俊 on 14-6-5.
|
||||
// Copyright (c) 2014年 Chenyanjun. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ImagePlayerView.h"
|
||||
|
||||
#define kStartTag 1000
|
||||
#define kDefaultScrollInterval 2
|
||||
|
||||
@interface ImagePlayerView() <UIScrollViewDelegate>
|
||||
@property (nonatomic, strong) UIScrollView *scrollView;
|
||||
//@property (nonatomic, strong) NSArray *imageURLs;
|
||||
@property (nonatomic, assign) NSInteger count;
|
||||
@property (nonatomic, strong) NSTimer *autoScrollTimer;
|
||||
@property (nonatomic, strong) UIPageControl *pageControl;
|
||||
@property (nonatomic, strong) NSMutableArray *pageControlConstraints;
|
||||
@end
|
||||
|
||||
@implementation ImagePlayerView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self _init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self) {
|
||||
[self _init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self _init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
self.scrollInterval = kDefaultScrollInterval;
|
||||
|
||||
// scrollview
|
||||
self.scrollView = [[UIScrollView alloc] init];
|
||||
[self addSubview:self.scrollView];
|
||||
|
||||
self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
self.scrollView.pagingEnabled = YES;
|
||||
self.scrollView.bounces = NO;
|
||||
self.scrollView.showsHorizontalScrollIndicator = NO;
|
||||
self.scrollView.showsVerticalScrollIndicator = NO;
|
||||
self.scrollView.directionalLockEnabled = YES;
|
||||
|
||||
self.scrollView.delegate = self;
|
||||
|
||||
// UIPageControl
|
||||
self.pageControl = [[UIPageControl alloc] init];
|
||||
self.pageControl.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
self.pageControl.numberOfPages = self.count;
|
||||
self.pageControl.currentPage = 0;
|
||||
[self addSubview:self.pageControl];
|
||||
|
||||
NSArray *pageControlVConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[pageControl]-0-|"
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:@{@"pageControl": self.pageControl}];
|
||||
|
||||
NSArray *pageControlHConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[pageControl]-|"
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:@{@"pageControl": self.pageControl}];
|
||||
|
||||
self.pageControlConstraints = [NSMutableArray arrayWithArray:pageControlVConstraints];
|
||||
[self.pageControlConstraints addObjectsFromArray:pageControlHConstraints];
|
||||
|
||||
[self addConstraints:self.pageControlConstraints];
|
||||
|
||||
}
|
||||
|
||||
// @deprecated use - (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate instead
|
||||
- (void)initWithImageURLs:(NSArray *)imageURLs placeholder:(UIImage *)placeholder delegate:(id<ImagePlayerViewDelegate>)delegate
|
||||
{
|
||||
[self initWithCount:imageURLs.count delegate:delegate edgeInsets:UIEdgeInsetsZero];
|
||||
}
|
||||
|
||||
// @deprecated use - (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate edgeInsets:(UIEdgeInsets)edgeInsets instead
|
||||
- (void)initWithImageURLs:(NSArray *)imageURLs placeholder:(UIImage *)placeholder delegate:(id<ImagePlayerViewDelegate>)delegate edgeInsets:(UIEdgeInsets)edgeInsets
|
||||
{
|
||||
[self initWithCount:imageURLs.count delegate:delegate edgeInsets:edgeInsets];
|
||||
}
|
||||
|
||||
- (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate
|
||||
{
|
||||
[self initWithCount:count delegate:delegate edgeInsets:UIEdgeInsetsZero];
|
||||
}
|
||||
|
||||
- (void)initWithCount:(NSInteger)count delegate:(id<ImagePlayerViewDelegate>)delegate edgeInsets:(UIEdgeInsets)edgeInsets
|
||||
{
|
||||
self.count = count;
|
||||
self.imagePlayerViewDelegate = delegate;
|
||||
|
||||
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:|-%d-[scrollView]-%d-|", (int)edgeInsets.top, (int)edgeInsets.bottom]
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:@{@"scrollView": self.scrollView}]];
|
||||
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"H:|-%d-[scrollView]-%d-|", (int)edgeInsets.left, (int)edgeInsets.right]
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:@{@"scrollView": self.scrollView}]];
|
||||
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.pageControl.numberOfPages = count;
|
||||
self.pageControl.currentPage = 0;
|
||||
|
||||
CGFloat startX = self.scrollView.bounds.origin.x;
|
||||
CGFloat width = self.bounds.size.width - edgeInsets.left - edgeInsets.right;
|
||||
CGFloat height = self.bounds.size.height - edgeInsets.top - edgeInsets.bottom;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
startX = i * width;
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(startX, 0, width, height)];
|
||||
imageView.contentMode = UIViewContentModeScaleToFill;
|
||||
imageView.tag = kStartTag + i;
|
||||
imageView.userInteractionEnabled = YES;
|
||||
imageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]];
|
||||
|
||||
[imageView addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]];
|
||||
[imageView addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:height]];
|
||||
|
||||
[self.imagePlayerViewDelegate imagePlayerView:self loadImageForImageView:imageView index:i];
|
||||
|
||||
[self.scrollView addSubview:imageView];
|
||||
}
|
||||
|
||||
// constraint
|
||||
NSMutableDictionary *viewsDictionary = [NSMutableDictionary dictionary];
|
||||
NSMutableArray *imageViewNames = [NSMutableArray array];
|
||||
for (int i = kStartTag; i < kStartTag + count; i++) {
|
||||
NSString *imageViewName = [NSString stringWithFormat:@"imageView%d", i - kStartTag];
|
||||
[imageViewNames addObject:imageViewName];
|
||||
|
||||
UIImageView *imageView = (UIImageView *)[self.scrollView viewWithTag:i];
|
||||
[viewsDictionary setObject:imageView forKey:imageViewName];
|
||||
}
|
||||
|
||||
[self.scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:|-0-[%@]-0-|", [imageViewNames objectAtIndex:0]]
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:viewsDictionary]];
|
||||
|
||||
NSMutableString *hConstraintString = [NSMutableString string];
|
||||
[hConstraintString appendString:@"H:|-0"];
|
||||
for (NSString *imageViewName in imageViewNames) {
|
||||
[hConstraintString appendFormat:@"-[%@]-0", imageViewName];
|
||||
}
|
||||
[hConstraintString appendString:@"-|"];
|
||||
|
||||
[self.scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:hConstraintString
|
||||
options:NSLayoutFormatAlignAllTop
|
||||
metrics:nil
|
||||
views:viewsDictionary]];
|
||||
|
||||
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * count, self.scrollView.frame.size.height);
|
||||
self.scrollView.contentInset = UIEdgeInsetsZero;
|
||||
}
|
||||
|
||||
- (void)handleTapGesture:(UIGestureRecognizer *)tapGesture
|
||||
{
|
||||
UIImageView *imageView = (UIImageView *)tapGesture.view;
|
||||
NSInteger index = imageView.tag - kStartTag;
|
||||
|
||||
if (self.imagePlayerViewDelegate && [self.imagePlayerViewDelegate respondsToSelector:@selector(imagePlayerView:didTapAtIndex:)]) {
|
||||
[self.imagePlayerViewDelegate imagePlayerView:self didTapAtIndex:index];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - auto scroll
|
||||
- (void)setAutoScroll:(BOOL)autoScroll
|
||||
{
|
||||
_autoScroll = autoScroll;
|
||||
|
||||
if (autoScroll) {
|
||||
if (!self.autoScrollTimer || !self.autoScrollTimer.isValid) {
|
||||
self.autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:self.scrollInterval target:self selector:@selector(handleScrollTimer:) userInfo:nil repeats:YES];
|
||||
}
|
||||
} else {
|
||||
if (self.autoScrollTimer && self.autoScrollTimer.isValid) {
|
||||
[self.autoScrollTimer invalidate];
|
||||
self.autoScrollTimer = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setScrollInterval:(NSUInteger)scrollInterval
|
||||
{
|
||||
_scrollInterval = scrollInterval;
|
||||
|
||||
if (self.autoScrollTimer && self.autoScrollTimer.isValid) {
|
||||
[self.autoScrollTimer invalidate];
|
||||
self.autoScrollTimer = nil;
|
||||
}
|
||||
|
||||
self.autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:self.scrollInterval target:self selector:@selector(handleScrollTimer:) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
- (void)handleScrollTimer:(NSTimer *)timer
|
||||
{
|
||||
if (self.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger currentPage = self.pageControl.currentPage;
|
||||
NSInteger nextPage = currentPage + 1;
|
||||
if (nextPage == self.count) {
|
||||
nextPage = 0;
|
||||
}
|
||||
|
||||
BOOL animated = YES;
|
||||
if (nextPage == 0) {
|
||||
animated = NO;
|
||||
}
|
||||
|
||||
UIImageView *imageView = (UIImageView *)[self.scrollView viewWithTag:(nextPage + kStartTag)];
|
||||
[self.scrollView scrollRectToVisible:imageView.frame animated:animated];
|
||||
|
||||
self.pageControl.currentPage = nextPage;
|
||||
}
|
||||
|
||||
#pragma mark - scroll delegate
|
||||
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
|
||||
// disable v direction scroll
|
||||
if (scrollView.contentOffset.y > 0) {
|
||||
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 0)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
||||
{
|
||||
// when user scrolls manually, stop timer and start timer again to avoid next scroll immediatelly
|
||||
if (self.autoScrollTimer && self.autoScrollTimer.isValid) {
|
||||
[self.autoScrollTimer invalidate];
|
||||
}
|
||||
self.autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:self.scrollInterval target:self selector:@selector(handleScrollTimer:) userInfo:nil repeats:YES];
|
||||
|
||||
// update UIPageControl
|
||||
CGRect visiableRect = CGRectMake(scrollView.contentOffset.x, scrollView.contentOffset.y, scrollView.bounds.size.width, scrollView.bounds.size.height);
|
||||
NSInteger currentIndex = 0;
|
||||
for (UIImageView *imageView in scrollView.subviews) {
|
||||
if ([imageView isKindOfClass:[UIImageView class]]) {
|
||||
if (CGRectContainsRect(visiableRect, imageView.frame)) {
|
||||
currentIndex = imageView.tag - kStartTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.pageControl.currentPage = currentIndex;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
- (void)setPageControlPosition:(ICPageControlPosition)pageControlPosition
|
||||
{
|
||||
NSString *vFormat = nil;
|
||||
NSString *hFormat = nil;
|
||||
|
||||
switch (pageControlPosition) {
|
||||
case ICPageControlPosition_TopLeft: {
|
||||
vFormat = @"V:|-0-[pageControl]";
|
||||
hFormat = @"H:|-[pageControl]";
|
||||
break;
|
||||
}
|
||||
|
||||
case ICPageControlPosition_TopCenter: {
|
||||
vFormat = @"V:|-0-[pageControl]";
|
||||
hFormat = @"H:|[pageControl]|";
|
||||
break;
|
||||
}
|
||||
|
||||
case ICPageControlPosition_TopRight: {
|
||||
vFormat = @"V:|-0-[pageControl]";
|
||||
hFormat = @"H:[pageControl]-|";
|
||||
break;
|
||||
}
|
||||
|
||||
case ICPageControlPosition_BottomLeft: {
|
||||
vFormat = @"V:[pageControl]-0-|";
|
||||
hFormat = @"H:|-[pageControl]";
|
||||
break;
|
||||
}
|
||||
|
||||
case ICPageControlPosition_BottomCenter: {
|
||||
vFormat = @"V:[pageControl]-0-|";
|
||||
hFormat = @"H:|[pageControl]|";
|
||||
break;
|
||||
}
|
||||
|
||||
case ICPageControlPosition_BottomRight: {
|
||||
vFormat = @"V:[pageControl]-0-|";
|
||||
hFormat = @"H:[pageControl]-|";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self removeConstraints:self.pageControlConstraints];
|
||||
|
||||
NSArray *pageControlVConstraints = [NSLayoutConstraint constraintsWithVisualFormat:vFormat
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:@{@"pageControl": self.pageControl}];
|
||||
|
||||
NSArray *pageControlHConstraints = [NSLayoutConstraint constraintsWithVisualFormat:hFormat
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:@{@"pageControl": self.pageControl}];
|
||||
|
||||
[self.pageControlConstraints removeAllObjects];
|
||||
[self.pageControlConstraints addObjectsFromArray:pageControlVConstraints];
|
||||
[self.pageControlConstraints addObjectsFromArray:pageControlHConstraints];
|
||||
|
||||
[self addConstraints:self.pageControlConstraints];
|
||||
}
|
||||
|
||||
- (void)setHidePageControl:(BOOL)hidePageControl
|
||||
{
|
||||
self.pageControl.hidden = hidePageControl;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface HomeViewController : UIViewController
|
||||
@interface HomeViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
//
|
||||
|
||||
#import "HomeViewController.h"
|
||||
|
||||
#import "MJRefresh.h"
|
||||
#import "HomeAdView.h"
|
||||
@interface HomeViewController ()
|
||||
|
||||
@end
|
||||
@@ -28,8 +29,82 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
[self.navigationItem setTitle:@"首页"];
|
||||
|
||||
//左边按钮
|
||||
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"左边按钮" style:UIBarButtonItemStyleDone target:self action:@selector(leftBarBtnClick:)]];
|
||||
|
||||
//右边按钮。
|
||||
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightBarBtnClick:)]];
|
||||
|
||||
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
[_tableView addHeaderWithTarget:self action:@selector(headerRereshing)];
|
||||
// [_tableView addFooterWithTarget:self action:@selector(footerRereshing)];
|
||||
|
||||
[_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark MJRefreshDelegate
|
||||
- (void)headerRereshing
|
||||
{
|
||||
|
||||
// 2.2秒后刷新表格UI
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// 刷新表格
|
||||
[self.tableView reloadData];
|
||||
|
||||
// (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
|
||||
[self.tableView headerEndRefreshing];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)footerRereshing
|
||||
{
|
||||
|
||||
// 2.2秒后刷新表格UI
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// 刷新表格
|
||||
[self.tableView reloadData];
|
||||
|
||||
// (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
|
||||
[self.tableView footerEndRefreshing];
|
||||
});
|
||||
}
|
||||
#pragma mark UITableViewDelegate
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
return 1;
|
||||
}
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return 1;
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *homeViewCell = @"HomeViewCell";
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:homeViewCell];
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:homeViewCell];
|
||||
HomeAdView* homeAdView = [[HomeAdView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 120)];
|
||||
[cell addSubview:homeAdView];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
#pragma mark - UIBarButtonClick 导航条两边按钮
|
||||
-(void)leftBarBtnClick:(id)sender
|
||||
{
|
||||
DLog(@"首页左边按钮");
|
||||
}
|
||||
-(void)rightBarBtnClick:(id)sender
|
||||
{
|
||||
DLog(@"首页右边按钮");
|
||||
[_tableView headerBeginRefreshing];
|
||||
}
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4469" systemVersion="13A476u" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3694"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeViewController">
|
||||
<connections>
|
||||
<outlet property="tableView" destination="f4k-6j-E3O" id="ssL-ql-hKU"/>
|
||||
<outlet property="view" destination="1" id="3"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
@@ -13,6 +14,13 @@
|
||||
<view contentMode="scaleToFill" id="1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="f4k-6j-E3O">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
|
||||
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MainViewController : UITabBarController
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,6 +22,24 @@
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
|
||||
//首页
|
||||
UINavigationController* homeNavigationController = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] init]];
|
||||
[homeNavigationController setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"icon_dock_home"] selectedImage:[UIImage imageNamed:@"icon_dock_home_actived"]]];
|
||||
[homeNavigationController.tabBarItem setBadgeValue:@"新"];
|
||||
//第二页
|
||||
UINavigationController* produciListNavigationController = [[UINavigationController alloc] initWithRootViewController:[[ProductListViewController alloc] init]];
|
||||
[produciListNavigationController setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"第二页" image:[UIImage imageNamed:@"icon_dock_session"] selectedImage:[UIImage imageNamed:@"icon_dock_session_actived"]]];
|
||||
//第三页
|
||||
UINavigationController* myNavigationController = [[UINavigationController alloc] initWithRootViewController:[[MyViewController alloc] init]];
|
||||
[myNavigationController setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"第三页" image:[UIImage imageNamed:@"icon_dock_mine"] selectedImage:[UIImage imageNamed:@"icon_dock_mine_actived"]]];
|
||||
//第四页
|
||||
UINavigationController* moreNavigationController = [[UINavigationController alloc] initWithRootViewController:[[MoreViewController alloc] init]];
|
||||
[moreNavigationController setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"第四页" image:[UIImage imageNamed:@"icon_dock_service"] selectedImage:[UIImage imageNamed:@"icon_dock_service_actived"]]];
|
||||
|
||||
self.viewControllers = @[homeNavigationController, produciListNavigationController, myNavigationController, moreNavigationController];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,7 @@
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ManagerConstants.h"
|
||||
#import "MKNetworkKit.h"
|
||||
#import "STableViewController.h"
|
||||
#endif
|
||||
|
||||
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1014 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 813 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -3,4 +3,6 @@ pod 'Reachability'
|
||||
pod 'SBJson'
|
||||
pod 'SDWebImage'
|
||||
pod 'MKNetworkKit'
|
||||
pod 'DTCoreText'
|
||||
pod 'DTCoreText'
|
||||
pod 'STableViewController'
|
||||
pod 'MJRefresh'
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Pods-DTCoreText.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/DTCoreText" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage"
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/DTCoreText" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC ${PODS_DTCORETEXT_OTHER_LDFLAGS}
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Pods-DTFoundation.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/DTFoundation" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" ${PODS_DTFOUNDATION_HEADER_SEARCH_PATHS}
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/DTFoundation" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController" ${PODS_DTFOUNDATION_HEADER_SEARCH_PATHS}
|
||||
OTHER_LDFLAGS = -ObjC ${PODS_DTFOUNDATION_OTHER_LDFLAGS}
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Pods-MKNetworkKit.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/MKNetworkKit" "${PODS_ROOT}/BuildHeaders/MKNetworkKit/Categories" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage"
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/MKNetworkKit" "${PODS_ROOT}/BuildHeaders/MKNetworkKit/Categories" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC ${PODS_MKNETWORKKIT_OTHER_LDFLAGS}
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Pods-Reachability.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/Reachability" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage"
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/Reachability" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC ${PODS_REACHABILITY_OTHER_LDFLAGS}
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Pods-SBJson.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/SBJson" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage"
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/SBJson" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Pods-SDWebImage.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/SDWebImage" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage"
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/SDWebImage" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC ${PODS_SDWEBIMAGE_OTHER_LDFLAGS}
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "Pods-STableViewController.xcconfig"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/STableViewController" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
@@ -0,0 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface PodsDummy_Pods_STableViewController : NSObject
|
||||
@end
|
||||
@implementation PodsDummy_Pods_STableViewController
|
||||
@end
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#import "Pods-environment.h"
|
||||
@@ -139,4 +139,26 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
## STableViewController
|
||||
|
||||
Copyright (C) 2011 by BJ Basañes, http://shikii.net
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Generated by CocoaPods - http://cocoapods.org
|
||||
|
||||
@@ -175,6 +175,32 @@ THE SOFTWARE.
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright (C) 2011 by BJ Basañes, http://shikii.net
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.</string>
|
||||
<key>Title</key>
|
||||
<string>STableViewController</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Generated by CocoaPods - http://cocoapods.org</string>
|
||||
|
||||
@@ -66,3 +66,9 @@
|
||||
#define COCOAPODS_VERSION_MINOR_SDWebImage_Core 7
|
||||
#define COCOAPODS_VERSION_PATCH_SDWebImage_Core 1
|
||||
|
||||
// STableViewController
|
||||
#define COCOAPODS_POD_AVAILABLE_STableViewController
|
||||
#define COCOAPODS_VERSION_MAJOR_STableViewController 0
|
||||
#define COCOAPODS_VERSION_MINOR_STableViewController 0
|
||||
#define COCOAPODS_VERSION_PATCH_STableViewController 1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "$(SDKROOT)/usr/include/libxml2"
|
||||
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers" -isystem "${PODS_ROOT}/Headers/DTCoreText" -isystem "${PODS_ROOT}/Headers/DTFoundation" -isystem "${PODS_ROOT}/Headers/MKNetworkKit" -isystem "${PODS_ROOT}/Headers/MKNetworkKit/Categories" -isystem "${PODS_ROOT}/Headers/Reachability" -isystem "${PODS_ROOT}/Headers/SBJson" -isystem "${PODS_ROOT}/Headers/SDWebImage"
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/STableViewController" "$(SDKROOT)/usr/include/libxml2"
|
||||
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers" -isystem "${PODS_ROOT}/Headers/DTCoreText" -isystem "${PODS_ROOT}/Headers/DTFoundation" -isystem "${PODS_ROOT}/Headers/MKNetworkKit" -isystem "${PODS_ROOT}/Headers/MKNetworkKit/Categories" -isystem "${PODS_ROOT}/Headers/Reachability" -isystem "${PODS_ROOT}/Headers/SBJson" -isystem "${PODS_ROOT}/Headers/SDWebImage" -isystem "${PODS_ROOT}/Headers/STableViewController"
|
||||
OTHER_LDFLAGS = -ObjC -lxml2 -framework CFNetwork -framework CoreGraphics -framework CoreText -framework ImageIO -framework MediaPlayer -framework QuartzCore -framework Security -framework SystemConfiguration
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F045554C5E934EA4B3506A68"
|
||||
BlueprintIdentifier = "17B5BBDE2AA74AD6927C83F1"
|
||||
BuildableName = "libPods-DTCoreText.a"
|
||||
BlueprintName = "Pods-DTCoreText"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "3837BE211A384AE99444E233"
|
||||
BlueprintIdentifier = "38D164B9D376486896BEE85B"
|
||||
BuildableName = "libPods-DTFoundation.a"
|
||||
BlueprintName = "Pods-DTFoundation"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "5B7AA494BBEC494094999B8B"
|
||||
BlueprintIdentifier = "FC20D0D069A0453EA4D3572D"
|
||||
BuildableName = "libPods-MKNetworkKit.a"
|
||||
BlueprintName = "Pods-MKNetworkKit"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7A07D5FAD8E342C9995FEEA9"
|
||||
BlueprintIdentifier = "70559D8DCB484E5C9855BDEF"
|
||||
BuildableName = "libPods-Reachability.a"
|
||||
BlueprintName = "Pods-Reachability"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E71D8A314753406BA2F332D4"
|
||||
BlueprintIdentifier = "EB2288CEDF154A2ABD7A59B3"
|
||||
BuildableName = "libPods-SBJson.a"
|
||||
BlueprintName = "Pods-SBJson"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D0C28A1B940D40379ABD25B4"
|
||||
BlueprintIdentifier = "8701DEFE19E54FDAA8ACF9CB"
|
||||
BuildableName = "libPods-SDWebImage.a"
|
||||
BlueprintName = "Pods-SDWebImage"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D667DD83988D470A910B259E"
|
||||
BlueprintIdentifier = "3C6F44C462904A05B04525A2"
|
||||
BuildableName = "libPods.a"
|
||||
BlueprintName = "Pods"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Pods-STableViewController.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Pods.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
@@ -42,37 +47,42 @@
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>3837BE211A384AE99444E233</key>
|
||||
<key>17B5BBDE2AA74AD6927C83F1</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>5B7AA494BBEC494094999B8B</key>
|
||||
<key>38D164B9D376486896BEE85B</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>7A07D5FAD8E342C9995FEEA9</key>
|
||||
<key>3C6F44C462904A05B04525A2</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>D0C28A1B940D40379ABD25B4</key>
|
||||
<key>70559D8DCB484E5C9855BDEF</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>D667DD83988D470A910B259E</key>
|
||||
<key>8701DEFE19E54FDAA8ACF9CB</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>E71D8A314753406BA2F332D4</key>
|
||||
<key>B4B317D35E3D4D3BB5DF69BB</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>F045554C5E934EA4B3506A68</key>
|
||||
<key>EB2288CEDF154A2ABD7A59B3</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>FC20D0D069A0453EA4D3572D</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// STableViewController.h
|
||||
//
|
||||
// @author Shiki
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@interface STableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
|
||||
|
||||
@protected
|
||||
|
||||
BOOL isDragging;
|
||||
BOOL isRefreshing;
|
||||
BOOL isLoadingMore;
|
||||
|
||||
// had to store this because the headerView's frame seems to be changed somewhere during scrolling
|
||||
// and I couldn't figure out why >.<
|
||||
CGRect headerViewFrame;
|
||||
}
|
||||
|
||||
// The view used for "pull to refresh"
|
||||
@property (nonatomic, retain) UIView *headerView;
|
||||
|
||||
// The view used for "load more"
|
||||
@property (nonatomic, retain) UIView *footerView;
|
||||
|
||||
@property (nonatomic, retain) UITableView *tableView;
|
||||
@property (readonly) BOOL isDragging;
|
||||
@property (readonly) BOOL isRefreshing;
|
||||
@property (readonly) BOOL isLoadingMore;
|
||||
@property (nonatomic) BOOL canLoadMore;
|
||||
|
||||
@property (nonatomic) BOOL pullToRefreshEnabled;
|
||||
|
||||
// Defaults to YES
|
||||
@property (nonatomic) BOOL clearsSelectionOnViewWillAppear;
|
||||
|
||||
// Just a common initialize method
|
||||
- (void) initialize;
|
||||
|
||||
#pragma mark - Pull to Refresh
|
||||
|
||||
// The minimum height that the user should drag down in order to trigger a "refresh" when
|
||||
// dragging ends.
|
||||
- (CGFloat) headerRefreshHeight;
|
||||
|
||||
// Will be called if the user drags down which will show the header view. Override this to
|
||||
// update the header view (e.g. change the label to "Pull down to refresh").
|
||||
- (void) willShowHeaderView:(UIScrollView *)scrollView;
|
||||
|
||||
// If the user is dragging, will be called on every scroll event that the headerView is shown.
|
||||
// The value of willRefreshOnRelease will be YES if the user scrolled down enough to trigger a
|
||||
// "refresh" when the user releases the drag.
|
||||
- (void) headerViewDidScroll:(BOOL)willRefreshOnRelease scrollView:(UIScrollView *)scrollView;
|
||||
|
||||
// By default, will permanently show the headerView by setting the tableView's contentInset.
|
||||
- (void) pinHeaderView;
|
||||
|
||||
// Reverse of pinHeaderView.
|
||||
- (void) unpinHeaderView;
|
||||
|
||||
// Called when the user stops dragging and, if the conditions are met, will trigger a refresh.
|
||||
- (void) willBeginRefresh;
|
||||
|
||||
// Override to perform fetching of data. The parent method [super refresh] should be called first.
|
||||
// If the value is NO, -refresh should be aborted.
|
||||
- (BOOL) refresh;
|
||||
|
||||
// Call to signal that refresh has completed. This will then hide the headerView.
|
||||
- (void) refreshCompleted;
|
||||
|
||||
#pragma mark - Load More
|
||||
|
||||
// The value of the height starting from the bottom that the user needs to scroll down to in order
|
||||
// to trigger -loadMore. By default, this will be the height of -footerView.
|
||||
- (CGFloat) footerLoadMoreHeight;
|
||||
|
||||
// Override to perform fetching of next page of data. It's important to call and get the value of
|
||||
// of [super loadMore] first. If it's NO, -loadMore should be aborted.
|
||||
- (BOOL) loadMore;
|
||||
|
||||
// Called when all the conditions are met and -loadMore will begin.
|
||||
- (void) willBeginLoadingMore;
|
||||
|
||||
// Call to signal that "load more" was completed. This should be called so -isLoadingMore is
|
||||
// properly set to NO.
|
||||
- (void) loadMoreCompleted;
|
||||
|
||||
// Helper to show/hide -footerView
|
||||
- (void) setFooterViewVisibility:(BOOL)visible;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// A helper method that calls refreshCompleted and/or loadMoreCompleted if any are active.
|
||||
- (void) allLoadingCompleted;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void) releaseViewComponents;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,326 @@
|
||||
//
|
||||
// STableViewController.m
|
||||
//
|
||||
// @author Shiki
|
||||
//
|
||||
|
||||
#import "STableViewController.h"
|
||||
|
||||
#define DEFAULT_HEIGHT_OFFSET 52.0f
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@implementation STableViewController
|
||||
|
||||
@synthesize tableView;
|
||||
@synthesize headerView;
|
||||
@synthesize footerView;
|
||||
|
||||
@synthesize isDragging;
|
||||
@synthesize isRefreshing;
|
||||
@synthesize isLoadingMore;
|
||||
|
||||
@synthesize canLoadMore;
|
||||
|
||||
@synthesize pullToRefreshEnabled;
|
||||
|
||||
@synthesize clearsSelectionOnViewWillAppear;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) initialize
|
||||
{
|
||||
pullToRefreshEnabled = YES;
|
||||
|
||||
canLoadMore = YES;
|
||||
|
||||
clearsSelectionOnViewWillAppear = YES;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
[self initialize];
|
||||
return self;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
if ((self = [super initWithCoder:aDecoder]))
|
||||
[self initialize];
|
||||
return self;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.tableView = [[[UITableView alloc] init] autorelease];
|
||||
tableView.frame = self.view.bounds;
|
||||
tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
tableView.dataSource = self;
|
||||
tableView.delegate = self;
|
||||
|
||||
[self.view addSubview:tableView];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
if (clearsSelectionOnViewWillAppear) {
|
||||
NSIndexPath *selected = [self.tableView indexPathForSelectedRow];
|
||||
if (selected)
|
||||
[self.tableView deselectRowAtIndexPath:selected animated:animated];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Pull to Refresh
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) setHeaderView:(UIView *)aView
|
||||
{
|
||||
if (!tableView)
|
||||
return;
|
||||
|
||||
if (headerView && [headerView isDescendantOfView:tableView])
|
||||
[headerView removeFromSuperview];
|
||||
[headerView release]; headerView = nil;
|
||||
|
||||
if (aView) {
|
||||
headerView = [aView retain];
|
||||
|
||||
CGRect f = headerView.frame;
|
||||
headerView.frame = CGRectMake(f.origin.x, 0 - f.size.height, f.size.width, f.size.height);
|
||||
headerViewFrame = headerView.frame;
|
||||
|
||||
[tableView addSubview:headerView];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (CGFloat) headerRefreshHeight
|
||||
{
|
||||
if (!CGRectIsEmpty(headerViewFrame))
|
||||
return headerViewFrame.size.height;
|
||||
else
|
||||
return DEFAULT_HEIGHT_OFFSET;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) pinHeaderView
|
||||
{
|
||||
[UIView animateWithDuration:0.3 animations:^(void) {
|
||||
self.tableView.contentInset = UIEdgeInsetsMake([self headerRefreshHeight], 0, 0, 0);
|
||||
}];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) unpinHeaderView
|
||||
{
|
||||
[UIView animateWithDuration:0.3 animations:^(void) {
|
||||
self.tableView.contentInset = UIEdgeInsetsZero;
|
||||
}];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) willBeginRefresh
|
||||
{
|
||||
if (pullToRefreshEnabled)
|
||||
[self pinHeaderView];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) willShowHeaderView:(UIScrollView *)scrollView
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) headerViewDidScroll:(BOOL)willRefreshOnRelease scrollView:(UIScrollView *)scrollView
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (BOOL) refresh
|
||||
{
|
||||
if (isRefreshing)
|
||||
return NO;
|
||||
|
||||
[self willBeginRefresh];
|
||||
isRefreshing = YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) refreshCompleted
|
||||
{
|
||||
isRefreshing = NO;
|
||||
|
||||
if (pullToRefreshEnabled)
|
||||
[self unpinHeaderView];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Load More
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) setFooterView:(UIView *)aView
|
||||
{
|
||||
if (!tableView)
|
||||
return;
|
||||
|
||||
tableView.tableFooterView = nil;
|
||||
[footerView release]; footerView = nil;
|
||||
|
||||
if (aView) {
|
||||
footerView = [aView retain];
|
||||
|
||||
tableView.tableFooterView = footerView;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) willBeginLoadingMore
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) loadMoreCompleted
|
||||
{
|
||||
isLoadingMore = NO;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (BOOL) loadMore
|
||||
{
|
||||
if (isLoadingMore)
|
||||
return NO;
|
||||
|
||||
[self willBeginLoadingMore];
|
||||
isLoadingMore = YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (CGFloat) footerLoadMoreHeight
|
||||
{
|
||||
if (footerView)
|
||||
return footerView.frame.size.height;
|
||||
else
|
||||
return DEFAULT_HEIGHT_OFFSET;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) setFooterViewVisibility:(BOOL)visible
|
||||
{
|
||||
if (visible && self.tableView.tableFooterView != footerView)
|
||||
self.tableView.tableFooterView = footerView;
|
||||
else if (!visible)
|
||||
self.tableView.tableFooterView = nil;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) allLoadingCompleted
|
||||
{
|
||||
if (isRefreshing)
|
||||
[self refreshCompleted];
|
||||
if (isLoadingMore)
|
||||
[self loadMoreCompleted];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - UIScrollViewDelegate
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
||||
{
|
||||
if (isRefreshing)
|
||||
return;
|
||||
isDragging = YES;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
if (!isRefreshing && isDragging && scrollView.contentOffset.y < 0) {
|
||||
[self headerViewDidScroll:scrollView.contentOffset.y < 0 - [self headerRefreshHeight]
|
||||
scrollView:scrollView];
|
||||
} else if (!isLoadingMore && canLoadMore) {
|
||||
CGFloat scrollPosition = scrollView.contentSize.height - scrollView.frame.size.height - scrollView.contentOffset.y;
|
||||
if (scrollPosition < [self footerLoadMoreHeight]) {
|
||||
[self loadMore];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
|
||||
{
|
||||
if (isRefreshing)
|
||||
return;
|
||||
|
||||
isDragging = NO;
|
||||
if (scrollView.contentOffset.y <= 0 - [self headerRefreshHeight]) {
|
||||
if (pullToRefreshEnabled)
|
||||
[self refresh];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) releaseViewComponents
|
||||
{
|
||||
[headerView release]; headerView = nil;
|
||||
[footerView release]; footerView = nil;
|
||||
[tableView release]; tableView = nil;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) dealloc
|
||||
{
|
||||
[self releaseViewComponents];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) viewDidUnload
|
||||
{
|
||||
[self releaseViewComponents];
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
@end
|
||||