- 普通樣式和分組樣式有分組标簽時 普通樣式會在上方和下方标示出來分組樣式不會顯示隻是在自己的組上下方有标示。
- Accessory 有兩個類型 accessorytype accessoryView
- 在viewDidLoad中 Self.tableView.rowHeight = 80設定的是所有的cell
- 設定一個單元格要在UITableViewDelegate中設定
- dataSource和delegate的差別
Datasource是在界面搭建之前
Delegate是在資料加載之後
- Cell重用隻會建立目前界面個數 + 1 //并不是絕對的
再次拖動會把前面出去的調用到後面
資料要放在外面
- 分割線是separator屬性
Self.tableView.separatorInset uiedgeinsetsMake
修改它會修改圖檔文字和labeltext和detailtext之間的距離 但是右邊不會根據他的改變而改變
- 啟動圖會影響進入手機時的螢幕樣式
- Imageviewtextlabeldetaitextlabelaccessoryaccessorytypebackgroundviewaccessoryview
Selectedbackgroundview
Detaitextlabel表格中小的描述内容
Accessory是附件
- 重用cell是從tableview中擷取的(dequeue)
- 模型嵌套第二次是在set方法中執行
- Sectionindextitle --- 側邊欄
- Uitextfield *textfield = [alert textfieldAtIndex:0];
Textfield.text = hero.name;
0代表擷取到第一個行中,如果兩個比如有password 如果是1則顯示到password中
- 從網上擷取要重新整理全界面就要全局重新整理
- Uialertview
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
// NSLog(@"%ld", (long)indexPath.row);
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"修改英雄"message:@"修改這個英雄名稱"delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"修改",nil];
alert.alertViewStyle =UIAlertViewStylePlainTextInput;
CZHero *hero =self.heroArray[indexPath.row];
self.indexPath= indexPath;
[alerttextFieldAtIndex:0].text = hero.name;
alert.delegate =self;
[alertshow];
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==1) {
NSString *str =[alertViewtextFieldAtIndex:0].text;
CZHero *hero =self.heroArray[self.indexPath.row];
hero.name = str;
[self.tableViewreloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationLeft];
}
}
23.Ios9方法
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
UIAlertController *alert = [UIAlertControlleralertControllerWithTitle:@"My alert"message:@"This isalert"preferredStyle:UIAlertControllerStyleAlert];
// UIAlertControllerStyleAlert
// UIAlertControllerStyleActionSheet從底部上來
[alertaddTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) {
CZHero *hero =self.heroArray[indexPath.row];
textField.text = hero.name;
}];
UIAlertAction *defaultAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *_Nonnullaction) {
}];
UIAlertAction *xiuGAction = [UIAlertActionactionWithTitle:@"修改"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnullaction) {
CZHero *hero =self.heroArray[indexPath.row];
hero.name = alert.textFields[0].text;
[self.tableViewreloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationLeft];
}];
// UIAlertAction *goodAction = [UIAlertActionactionWithTitle:@"" style:<#(UIAlertActionStyle)#>handler:<#^(UIAlertAction * _Nonnull action)handler#>]
[alertaddAction:defaultAction];
[alertaddAction:xiuGAction];
[selfpresentViewController:alertanimated:YEScompletion:^{
nil;
}];
}
- 當删除資料的時候 , 他要判斷cell的數量和資料的數量是否相同。 如果相同則删除 , 如果不同報錯。 是以再删除方法之前要移除nsmutableView的相應資料。
- Info.plist 放在檔案夾中第一級目錄中
- Is initial view controller 第一個啟動界面
- uitableViewcontroller 目前界面隻能是uitableView
- uitableViewController 中的self.uiview 和 self.uitableView 記憶體位址相等
- Xib 是一個數組 裡邊是你所定義的類型
- Xib 的identity 要設定在屬性檢測器裡。
- Self.tableVeiew.tableheaderView = view. 隻有高有用
Self.tableView.tableFooterView = view 隻有高和x有用
上下不能共用一個uiview 否則下方不顯示
- tableViewCell ID标示要加static 放在對象區
靜态區就是在對象在用的時候存在而在對象銷毀的時候銷毀
- 轉圈的要設定animal 才能轉
- Awakefromnib
加載完xib之後想對他做操作的時候可以使用
- Kvc 可以自動進行類型轉換, 前提是他能轉。
- @property(nonatomic, assign, getter = isVip) BOOL vip;
- 模型中的資料隻能比plist多不能比他少
- 自定義cell 空間添加到contentcell中
- CGRect bounds = [userName boundingRectWithSize-----]
- Label 換行 lines 換行 self。Messagelabel.numberOfLines = 0
- uitableViewController 全屏滑動
- 當發現項目中有啟動圖和appicon圖示的時候先設定這兩個在改變檔案夾
- 當有多人聊天 可以定義枚舉
- 自定義textField 先設定為無邊框 再設定backgroundImage
- 目前時間是否隐藏 :
在字典轉模型中判斷, mArray 中存在上一次的 而且轉成功的是目前的進行對比
在原來模型中設定BOOL是否顯示屬性。
Self.hidden
- 輸入完之後跳到最後一行
//4. 讓talbView滾動到最後一行
// > 4.1 定義一個NSIndexPath
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(self.messageArray.count-1) inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
- 使用通知之後一定記得要移除通知
- (void)dealloc{
//通知移除
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
- Nsdate 的使用
NSDate *date = [NSDatedate];
NSDateFormatter *dateFormate = [[NSDateFormatter alloc] init];
dateFormate.dateFormat = @"HH:mm";
NSString *dateStr = [dateFormate stringFromDate:date];
- textField 的監聽return 的機制
- (BOOL)textFieldShouldReturn:(UITextField *)textField
- 裁剪圖檔
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(image.size.height * 0.5, image.size.width * 0.5, image.size.height * 0.5, image.size.width * 0.5) resizingMode:UIImageResizingModeTile];
- 内部邊距很重要 設定完邊距要調整原來在frame中設定的寬高和x進行調整
self.messageBtn.titleEdgeInsets = UIEdgeInsetsMake(20, 20, 20, 20);
- 通知
1. // WithName 第一個參數:name 代表通知的名稱
// object : 代表發送通知的對象
// userInfo :代表附加資訊
// [NSNotificationnotificationWithName:<#(nonnull NSString *)#> object:<#(nullableid)#> userInfo:<#(nullable NSDictionary *)#>]
2. //監聽者一定要在通知釋出之前進行監聽
//是用通知中心進行添加
// addObserver 第一個參數對象 ->哪個對象進行監聽
// selector 第一個參數對象,監聽到消息之後,觸發什麼方法
// 這個方法,要解除安裝對應的對象,它的類中,它是一個對象的方法,是以是一個執行個體方法
// name ->釋出通知的名字 當把名字設定為Nil的時候,代表任何名字的通知都接收
// object ->釋出的對象 當object設定為Nil的時候,代表接收任何對象的通知、
[notificationCenter addObserver:<#(nonnull id)#>selector:<#(nonnull SEL)#> name:<#(nullable NSString *)#>object:<#(nullable id)#>]
3. //沒有對象的時候發送通知
//這是發送通知的方法
// postNotificationName 發送通知的名字
// object 代表發送通知的對象
// userInfo 額外的資訊
// [notificationCenterpostNotificationName:<#(nonnull NSString *)#> object:<#(nullableid)#> userInfo:<#(nullable NSDictionary *)#>]