デリゲート メソッドを使用して、popToRootViewController の後にビューを強制的に更新しました。私の rootViewController はネットワーク アップロード クラスを呼び出し、完了したら、rootViewController のフォーム フィールドをリセットしたいと考えました。
ネットワーク アップロード クラスでは、デリゲート プロトコルを作成しました。
@protocol MyNetworkDelegate <NSObject>
@required
- (void) uploadCompleted;
@end
@interface MyNetworkUploader : NSObject{
id <MyNetworkDelegate> _delegate;
}
@property (nonatomic,strong) id delegate;
//other properties here
+(id)sharedManager;
-(int)writeAssessments;
@end
MyNetworkUploader.m で:
-(int)writeAssessments{
//code here to do the actual upload
//.....
//this is a non-view class so I use a global navigation controller
//maybe not the best form but it works for me and I get the required
//behaviour
[globalNav popToRootViewControllerAnimated:NO];
[[globalNav.view viewWithTag:1] removeFromSuperview];
[_delegate uploadCompleted];
}
次に、私の rootViewController で:
//my upload is done within a completion block so I know when
//it's finished
typedef void(^myCompletion)(BOOL);
-(void) uploadAssessment:(myCompletion) compblock{
//do the upload
sharedManager=[MyNetwork sharedManager]; //create my instance
sharedManager.delegate=self; //set my rootViewController as the network class delegate
int numWritten= [sharedManager writeAssessments];
compblock(YES);
}
#pragma mark - protocol delegate
-(void)uploadCompleted{
//this is a local method that clears the form
[self clearTapped:nil];
}
これが最善の解決策であると提案しているわけではありませんが、私にとってはうまくいきました!