뷰 컨트롤러 내부에 uitableview가 있고 내 uitableview 아래에 버튼이 있습니다. 이 버튼을 누르면 모달 뷰가 열립니다. 내 jQuery과에서, 모든 데이터를 내 모달 뷰를 닫 누를 때모달 뷰가 닫힐 때 iOS Obj-C - UITableView 데이터가 사라짐
- (IBAction)closeButton:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
그러나
modalview.m : 나는 다음과 같은 코드를 사용하여 내 모달 내부의 '닫기'버튼을 만들었습니다 사라질 것 같습니다 (uitableview는 그냥 흰색으로 간다)? 왜 이런 일이 일어날 지, 어떻게 해결할 수 있습니까? 여기 내있는 tableview 데이터 (이 도움이되기를 바랍니다)로드 및 구성 방식입니다 :
ViewController.m
-(void)updateMessages {
self.tableView.dataSource = self;
NSMutableDictionary *viewParams = [NSMutableDictionary new];
[viewParams setValue:@"name" forKey:@"view_name"];
[DIOSView viewGet:viewParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.messages = (NSMutableArray *)responseObject;
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Failure: %@", [error localizedDescription]);
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self updateMessages];
static NSString *ChatTableIdentifier = @"ChatTableViewCell";
static NSString *ChatTableIdentifier2 = @"SwapDetailTableViewCell";
UINib *nib = [UINib nibWithNibName: ChatTableIdentifier bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier: ChatTableIdentifier];
UINib *nib2 = [UINib nibWithNibName: ChatTableIdentifier2 bundle:nil];
[self.tableView registerNib:nib2 forCellReuseIdentifier: ChatTableIdentifier2];
self.tableView.dataSource = self;
[self.tableView reloadData];
}
- (int)numberOfSectionsInTableView: (UITableView *)tableview
{
return 1;
}
- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.messages count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *data = self.messages[indexPath.row];
id swaptime = data[@"swaptime"];
if ([swaptime isKindOfClass:[NSString class]]) {
// There is a valid "swaptime" value
static NSString *ChatTableIdentifier2 = @"SwapDetailTableViewCell";
SwapDetailTableViewCell *cell = (SwapDetailTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ChatTableIdentifier2 forIndexPath:indexPath];
NSString *time = data[@"swaptime"];
cell.startTime.text = time;
NSString *timeEnd = data[@"endswaptime"];
cell.endTime.text = timeEnd;
NSString *costofSwap = data[@"swapvalue"];
cell.swapValue.text = costofSwap;
NSString *fromUsername = data[@"first name"];
cell.fromUser.text = fromUsername;
NSString *pet = data[@"pet's name"];
cell.petsname.text = pet;
NSString *swapStatus = data[@"swapaccepted"];
if ([swapStatus isEqual: @"Yes"]) {
[cell.displayedBar setImage:[UIImage imageNamed:@"greenbar.png"]];
cell.swapTitle.text = @"Accepted!";}
else {
if ([swapStatus isEqual: @""]) {
[cell.displayedBar setImage:[UIImage imageNamed:@"orangecellbar.png"]];
cell.swapTitle.text = @"You have a Request!";}
if ([swapStatus isEqual: @"Requested"]) {
[cell.displayedBar setImage:[UIImage imageNamed:@"orangecellbar.png"]];
cell.swapTitle.text = @"You have a Request!";}
if ([swapStatus isEqual: @"Cancelled"]) {
[cell.displayedBar setImage:[UIImage imageNamed:@"blueecellbar.png"]];
cell.swapTitle.text = @"Cancelled!";}
if ([swapStatus isEqual: @"No"]) {
[cell.displayedBar setImage:[UIImage imageNamed:@"redbar.png"]];
cell.swapTitle.text = @"Declined!";
}
}
return cell;
} else {
static NSString *ChatTableIdentifier = @"ChatTableViewCell";
ChatTableViewCell *cell = (ChatTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ChatTableIdentifier forIndexPath:indexPath];
NSString *userName = data[@"first name"];
cell.sendingUser.text = userName;
NSString *messageBody = data[@"body"];
cell.messageDisplayed.text = messageBody;
NSString *timeReceived = data[@"published at"];
cell.timeStamp.text = timeReceived;
NSString *userInfo = [self.userid objectForKey:@"first name"];
if ([cell.sendingUser.text isEqual: userInfo]) {
cell.messageDisplayed.textAlignment = NSTextAlignmentLeft;
cell.sendingUser.textAlignment = NSTextAlignmentLeft;
[cell.chatBubble setImage:[UIImage imageNamed:@"bubblegrey2.png"]];
} else {
cell.messageDisplayed.textAlignment = NSTextAlignmentRight;
cell.sendingUser.textAlignment = NSTextAlignmentRight;
[cell.chatBubble setImage:[UIImage imageNamed:@"bubbleorange2.png"]];
}
return cell;
}
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView setContentOffset:CGPointMake(0, CGFLOAT_MAX)];
}
'viewWillAppear'또는 'viewDidAppear'에 무엇이 있습니까? 또는 귀하의 모달에서 tableView에 영향을주는 것은 무엇입니까? 테이블보기에 배경색을 추가하고 아직 그 모습이 보이거나 사라 졌는지 확인하십시오. – Tj3n
@ Tj3n viewDidAppear의 내용은 위의 편집을 참조하십시오. 나는 사용자가이 뷰에 착륙 할 때 자동으로 테이블 뷰의 맨 아래로 스크롤되도록 만들었습니다. 내가 사용한 코드가 효과가 있습니까? – Brittany
왜 테이블 뷰의 내용 오프셋을 이렇게 큰 값으로 설정하고 있습니까? 그 라인의 목표는 무엇입니까? – rmaddy