저는 아직 iOS에 익숙하지 않습니다. 개발중인 앱에는 사용자가 외부 소스에서 파일을 가져올 때 표시되는보기가 있습니다.iOS : 디스패치 대기열 요청을 시작하기 전에 ActionSheet를 통해 확인하도록 사용자에게 묻습니다.
사용자가 응용 프로그램에서 파일을 열고 자신의 이메일에서 choses : 사용자가 다음과 같이 액션 시트에, 관계의 계층임을 확인 후 나는 단지 실행 가져 오기를하고 싶습니다.
그러면 그는 progressView (가져 오기 프로세스 중에 프로그래밍 방식으로 루트보기가됩니다)로 전환됩니다.
프로세스가 완료되고 기본 rootview가 다시 설정됩니다.
는 내가 원하는 사용자가 정말 progressView 쇼 즉시 수입하고자하는 경우 요청하는 것입니다, 그는 그것을 취소가되지 않을 경우
감사를 (내가 그것을하는 방법을 모른다)
- (void)handleImportURL:(NSURL *)url
{
__block JASidePanelController * controller = (JASidePanelController *)self.window.rootViewController;
// Show progress window
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
__block PVProgressViewController * progressController = [storyboard instantiateViewControllerWithIdentifier:@"kProgressViewController"];
self.window.rootViewController = progressController;
// I think here somethings needs to be done with UIActionsheet
// Perform import operation
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSError *outError;
NSString * csvString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&outError];
NSArray * array = [csvString csvRows];
[[PVDatabaseController sharedController] importArray:array progressHandler:^(float progress) {
progressController.progressBar.progress = progress;
}];
dispatch_async(dispatch_get_main_queue(), ^{
self.window.rootViewController = controller;
});
});
}
업데이트 : 그래서 여기 나는 액션 시트와 함께 할 뭘하려 :
당신은 여기 는 기능입니다 6,//First the function that calls the handleImport
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// Handle CSV Import
if (url != nil && [url isFileURL]) {
[self handleImportURL:url];
[self confirmImportAlert];
}
return YES;
}
//은 액션 시트를 표시하려면
- (void)confirmImportAlert {
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Proceed through Import?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Yes", @"Maybe", nil];
[myActionSheet showInView: self.window];
}
// what to do
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 0){
// Avoid Import
}
else{
[self handleImportURL:_importURL];
//initiate import
}
}
업데이트 2 :는 그래서 추가 (I 앱 위임의 ActionSheetWilldismiss 함수를 호출하는 것 캔트) 두 가지 방법을 변경 :
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSString *choice = [ actionSheet buttonTitleAtIndex:buttonIndex];
if(buttonIndex == 0){
//initiate import
[self handleImportURL:_importURL];
}
else{
//don't initiate import
}
}
//This methods creats the action sheet
- (void)confirmImportAlert {
// importActionSheet is a property in the appdelegate.h
if (!self.importActionSheet){
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Proceed through Import?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Yes", nil];
[myActionSheet showInView: self.window];
myActionSheet.delegate = self;
self.importActionSheet = myActionSheet;
}
}
가져 오기를 호출하는 기능을 다음과 같이 변경했습니다.
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// Handle CSV Import
if (url != nil && [url isFileURL]) {
[self confirmImportAlert];
//[self handleImportURL:url];
}
return YES;
}
안녕하세요, 작업 표를 추가하려고 시도했지만 (위 참조) OpenUrl 함수에서 [self handleImportURL : url]을 제거하면 작동하지 않습니다. –