我正在做的是应用推送视图控制器从表视图的 didSelectMethod 移动到下一个视图。并在下一个视图控制器数据中获取该视图。所以,问题是视图只有在完全获取数据时才会切换,并且它同时包含图像和文本。但我已经为图像应用了延迟加载,但问题是立即移动到下一个视图,然后获取数据并更新 UI 和表格视图。下面是我正在尝试的代码。
在下一个视图控制器的 didLoad 方法上。
[NSThread detachNewThreadSelector:@selector(setImage) toTarget:self withObject:nil];
方法 setImage 获取所有数据图像和文本。
-(void)setImage
{
if([type isEqualToString:@"Organisation"])
{
self.mGetDataDict = [MyEventApi members:self.mUserIdDict];
self.mRecievedDataDict = [self.mGetDataDict valueForKey:@"members"];
}
if([type isEqualToString:@"Individual"]){
self.mGetDataDict = [MyEventApi friends:self.mUserIdDict];
self.mRecievedDataDict = [self.mGetDataDict valueForKey:@"friends"];
}
if([self.mGetDataDict valueForKey:@"friends"] == [NSNull null])
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"alert" message:@"You have not added any friend yet." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else
{
self.mFrndNameArr = [[NSMutableArray alloc]init];
self.mFrndImgArr = [[NSMutableArray alloc]init];
self.mFirstNameArr = [[NSMutableArray alloc]init];
self.mLastNameArr = [[NSMutableArray alloc]init];
self.mFrndIdArr = [[NSMutableArray alloc]init];
self.mFrndMSinceArr = [[NSMutableArray alloc]init];
self.mFrndDescArr = [[NSMutableArray alloc]init];
self.mFrndNameArr = [self.mRecievedDataDict valueForKey:@"username"];
self.mFrndImgArr = [self.mRecievedDataDict valueForKey:@"image"];
self.mFirstNameArr = [self.mRecievedDataDict valueForKey:@"firstName"];
self.mLastNameArr = [self.mRecievedDataDict valueForKey:@"lastName"];
self.mFrndIdArr = [self.mRecievedDataDict valueForKey:@"id"];
self.mFrndMSinceArr = [self.mRecievedDataDict valueForKey:@"memberSince"];
self.mFrndDescArr = [self.mRecievedDataDict valueForKey:@"description"];
[self.mFriendsTable reloadData];
}
}
请指导以上,我使用的是正确的方法还是有其他方法可以做到这一点。提前致谢。