1.tableView的編輯模式
// 只在在tableview的編輯模式下才有添加
// 只要實現該方法, 手指在cell上面滑動的時候就自動實現了刪除按鈕
// commitEditingStyle: 傳入提交的編輯操作(刪除/添加)
// forRowAtIndexPath: 當前正在編輯的行
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
// 該方法用於刪除tableview上指定行的cell
// 注意:使用該方法的時候,模型中刪除的數據的條數必須和deleteRowsAtIndexPaths方法中刪除的條數一致,否則會報錯
// 簡而言之,就刪除的數據必須和刪除的cell保持一致
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
// 用於告訴系統開啓的編輯模式是什麼模式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
2.UITabBarController的簡單使用
UITabBarController的使用步驟
(1)初始化UITabBarController
(2)設置UIWindow的rootViewController爲UITabBarController
(3)根據具體情況,通過addChildViewController方法添加對應個數的子控制器
4.UITabBarController的子控制器
UITabBarController添加控制器的方式有2種
添加單個子控制器
- (void)addChildViewController:(UIViewController *)childController;
設置子控制器數組
@property(nonatomic,copy) NSArray*viewControllers;
5.UITabBarButton
UITabBarButton裏面顯示什麼內容,由對應子控制器的tabBarItem屬性決定
UITabBarItem有以下屬性影響着UITabBarButton的內容
標題文字
@property(nonatomic,copy) NSString *title;
圖標
@property(nonatomic,retain) UIImage *image;
選中時的圖標
@property(nonatomic,retain) UIImage *selectedImage;
提醒數字
@property(nonatomic,copy) NSString*badgeValue;
6.Modal
除了push之外,還有另外一種控制器的切換方式,那就是Modal
任何控制器都能通過Modal的形式展示出來
Modal的默認效果:新控制器從屏幕的最底部往上鑽,直到蓋住之前的控制器爲止
以Modal的形式展示控制器
- (void)presentViewController:(UIViewController *)viewControllerToPresentanimated: (BOOL)flag completion:(void (^)(void))completion
關閉當初Modal出來的控制器
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void(^)(void))completion;
7.tableView刷新、@property屬性補充知識
1.tableView的刷新
1> 數據刷新的總體步驟
* 修改模型數據
* 刷新表格(刷新界面)
2> 刷新表格(刷新界面)的方法
* 全局刷新(每一行都會重新刷新)
- (void)reloadData;
* 局部刷新(使用前提: 刷新前後, 模型數據的個數不變)
- (void)reloadRows:(NSArray*)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
* 局部刪除(使用前提: 模型數據減少的個數 == indexPaths的長度)
- (void)deleteRowsAtIndexPaths:(NSArray*)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
2.@property屬性的用法
* weak(assign) : 代理\UI控件
* strong(retain) : 其他對象(除代理\UI控件\字符串以外的對象)
* copy : 字符串
* assign : 非對象類型(基本數據類型int\float\BOOL\枚舉\結構體)