내가 채팅 응용 프로그램을 만드는 잠시 후 그 목적을 상실 : 배열, 내가 <code>arrayChat</code>에 메시지를 추가
-(void)msgRecevied:(NSMutableDictionary *)messageContent
{
NSString *m = [messageContent objectForKey:kMsg];
[messageContent setObject:[m substituteEmoticons] forKey:kMsg];
self.arrayTemp = messageContent;
[self.arrayChat addObject:self.arrayTemp];
[_tblChat reloadData];
if(self.arrayChat.count > 1){
NSIndexPath *topIndexPath = [NSIndexPath indexPathForRow:self.arrayChat.count-1
inSection:0];
[self.tblChat scrollToRowAtIndexPath:topIndexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
}
하지만 난 메시지를 보낼 때 난 몇 시간 동안 내 장치를 넣어 잠시 후, 그 후에는 추가
개체가arrayChat
에 있지만 tableView에로드되지 않고 테이블을 다시로드하면 마지막으로 잃어버린 객체가 표시됩니다 (
arrayChat
). 여기 또한
@synthesize arrayTemp;
모든 실수를
@interface ViewController : UIViewController
{
NSMutableArray *arrayChat;
}
@property (strong,nonatomic) NSMutableArray *arrayChat;
과 :
내가 좋아하는 arrayChat
를 선언?
편집
내가 추가 내 다른 클래스에 arrayChat
그리고 난 Appdelegate
에 그 클래스 내가 응용 프로그램에 해당 배열에 액세스 할 수 클래스를 사용 선언하고 일하고있어,하지만 난 배열에 객체를 추가 할 때 문제가 발생하지만, 한 번에 내 테이블을 다시로드하지 않고, 마지막으로 추가 한 배열 객체가 표시되도록 버튼에 채팅보기를 확대하고 있습니다. 여기
내 코드를 할 때 메신저 확대도이다 :이 해결 얼마나
-(IBAction)onClickViewLarge:(id)sender{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
if (!isShow) {
[_btnOpen setImage:[UIImage imageNamed:@"ico_expand"] forState:UIControlStateNormal];
[UIView animateWithDuration:0.5 animations:^{
if(screenHeight >= 736)
self.view.frame = CGRectMake(0,66 , screenWidth, screenHeight - 66);
else if (screenHeight >= 667)
self.view.frame = CGRectMake(0,60 , screenWidth, screenHeight - 60);
else if (screenHeight >= 568)
self.view.frame = CGRectMake(0,51 , screenWidth, screenHeight - 51);
else if (screenHeight >= 480)
self.view.frame = CGRectMake(0,43 , screenWidth, screenHeight - 43);
}];
isShow = true;
} else {
[_btnOpen setImage:[UIImage imageNamed:@"ico_open"] forState:UIControlStateNormal];
[UIView animateWithDuration:0.5 animations:^{
self.view.frame = CGRectMake(screenWidth - 250,screenHeight - 450 , 250, 450);
}];
isShow = false;
}
if([app.Glb.arrayChat count] > 0)
{
[self.tblChat reloadData];
NSIndexPath *topIndexPath = [NSIndexPath indexPathForRow:app.Glb.arrayChat.count-1
inSection:0];
[self.tblChat scrollToRowAtIndexPath:topIndexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
}
?
문제는 글로벌 arrayTemp 객체와 같다고 생각합니다. msgRecevied 메서드 내에서 선언 해보십시오. – Arun
아무 효과가 없습니다. – Kabali
arrayTemp도 강합니까? 강하게 설정하지 않은 경우. 나는 언젠가 그 설정을 무의미한 것으로 생각한다. –