Skip to content

Commit

Permalink
dev:修复所有笔记界面TableView底部不显示的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyufeng1991 committed Nov 17, 2015
1 parent 016777b commit 3b0182f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
29 changes: 20 additions & 9 deletions Oncenote/AllNotesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ - (void)viewDidLoad {

//查询用户的笔记;
[self queryNoteByUserId:NOTE_TABLE userId:app.GLOBAL_USERID limitCount:50];

NSLog(@"AllNotesViewController---viewDidLoad");
}


Expand Down Expand Up @@ -96,19 +94,29 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
//左滑删除;
if (editingStyle == UITableViewCellEditingStyleDelete) {

//数据库删除;
[BmobOperation deleteNoteFromDatabase:NOTE_TABLE noteId:[[self.allNotesArray objectAtIndex:indexPath.row] valueForKey:@"noteId"]];

[self.allNotesArray removeObjectAtIndex:indexPath.row];//从数组中删除该值;
[self.noteTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

//数据库删除;

//////
if (100 * [self.allNotesArray count] < [UIScreen mainScreen].bounds.size.height) {
self.noteTableView.frame = CGRectMake(self.noteTableView.frame.origin.x, self.noteTableView.frame.origin.y, self.noteTableView.frame.size.width, 100 * [self.allNotesArray count]);
}else{
self.noteTableView.frame = CGRectMake(self.noteTableView.frame.origin.x, self.noteTableView.frame.origin.y, self.noteTableView.frame.size.width, [UIScreen mainScreen].bounds.size.height - 65);
}

}

}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

return 100;
}


#pragma mark - 界面跳转传递数据
Expand Down Expand Up @@ -154,13 +162,10 @@ - (void) queryNoteByUserId:(NSString*)tableName userId:(NSString*)userId limitCo


[self.allNotesArray addObject:note];

// NSLog(@"输入的用户Id:%@,返回的用户Id:%@,标题:%@,笔记内容:%@",userId,[obj objectForKey:@"userId"],[obj objectForKey:@"noteTitle"],[obj objectForKey:@"noteText"]);

}//if();
}//for();



if (self.tempTitle != nil && self.tempText != nil && self.tempIndexPath != nil) {

[[self.allNotesArray objectAtIndex:self.tempIndexPath.row] setValue:self.tempTitle forKey:@"noteTitle"];
Expand All @@ -175,9 +180,15 @@ - (void) queryNoteByUserId:(NSString*)tableName userId:(NSString*)userId limitCo

}//else();

// NSLog(@"笔记数组的count = %lu",(unsigned long)[self.allNotesArray count]);
NSLog(@"笔记数组的count = %lu",(unsigned long)[self.allNotesArray count]);

//解决TableView不能滚到最下面的bug;注意如何设置TableView的长度;
if (100 * [self.allNotesArray count] < [UIScreen mainScreen].bounds.size.height) {
self.noteTableView.frame = CGRectMake(self.noteTableView.frame.origin.x, self.noteTableView.frame.origin.y, self.noteTableView.frame.size.width, 100 * [self.allNotesArray count]);
}else{
self.noteTableView.frame = CGRectMake(self.noteTableView.frame.origin.x, self.noteTableView.frame.origin.y, self.noteTableView.frame.size.width, [UIScreen mainScreen].bounds.size.height - 65);
}

self.noteTableView.frame = CGRectMake(self.noteTableView.frame.origin.x, self.noteTableView.frame.origin.y, self.noteTableView.frame.size.width, [self.allNotesArray count] * 100);

[self.noteTableView reloadData];

Expand Down
4 changes: 2 additions & 2 deletions Oncenote/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,8 @@
<animations/>
<color key="backgroundColor" red="0.89019607840000003" green="0.89019607840000003" blue="0.89019607840000003" alpha="1" colorSpace="calibratedRGB"/>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" id="2DD-2q-VZ2">
<rect key="frame" x="0.0" y="74" width="320" height="300"/>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" dataMode="prototypes" style="plain" separatorStyle="default" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" id="2DD-2q-VZ2">
<rect key="frame" x="0.0" y="66" width="320" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand Down
2 changes: 1 addition & 1 deletion Oncenote/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (void)viewDidLoad {
//设置navi中的用户名;
AppDelegate *app = [[UIApplication sharedApplication] delegate];

NSLog(@"22222222222222用户的昵称是:%@",app.GLOBAL_NICKNAME);
// NSLog(@"22222222222222用户的昵称是:%@",app.GLOBAL_NICKNAME);

if (app.GLOBAL_NICKNAME == nil || [app.GLOBAL_NICKNAME isEqualToString:@""]) {
self.naviUsername.text = app.GLOBAL_USERNAME;
Expand Down

0 comments on commit 3b0182f

Please sign in to comment.