2012-03-29 16 views
1

iphoneでボタンをタップしたときにファイルブラウザを開く方法.pdf形式の拡張子を持つファイルを表示する必要があります。たとえば、xyzに電子メールを送信する場合は、ファイルを送信するためにいくつかのファイルを添付します。ファイルボタンをクリックすると、ファイルエクスプローラが表示されます。ユーザーがiphoneのボタンをクリックすると、ファイルエクスプローラを開く必要があるのと同じ方法です。このうちから手伝ってください。ファイルブラウザを開き、iosで.pdfファイルを選択する方法

答えて

1

私のIOSアプリケーションと同様のことをしました。 IOSはファイルブラウザを持っていないので、アプリケーションサーフィスをクリックしてファイルを添付するだけで、UIPopoverControllerを開き、彼にすべてのファイルを表示します。欲しいです。私の場合の.csvファイルだったと私は、このアルゴリズムを使用します。_dataは、私は私が持っているすべてのCSVファイルを知っている私のtableViewに使う配列です

 _data= [[NSMutableArray alloc] init]; 
    NSString *documentsPath= [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
    NSError *error; 
    NSArray* files= [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error]; 
    NSRange range; 

    for (NSString* file in files) { 
     range = [file rangeOfString:@".csv" 
          options:NSCaseInsensitiveSearch]; 
     if (range.location!= NSNotFound) { 
      [_data addObject:file]; 
     } 
    } 

を。ファイルブラウザとしてディレクトリを表示したい場合は、ディレクトリにファイルを再帰的に表示させます。私のテーブルのデータソース:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
return [_data count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell==nil) { 
    cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; 
}  
cell.textLabel.text=[_data objectAtIndex:indexPath.row];  
return cell; 
} 

私はそれはあなた

役に立てば幸い
関連する問題