【问题标题】:tableview data doesn't display after dismissing modal view and no data changed关闭模式视图后不显示 tableview 数据并且没有数据更改
【发布时间】:2013-11-21 07:16:20
【问题描述】:

从 tableview 控制器,我显示一个模态视图来捕获视频剪辑... 取消后(无剪辑拍摄),图像选择器被关闭,表格视图重新显示但黑屏......似乎不再被填充......我错过了什么?

//  MySwingsViewController.h
#import <UIKit/UIKit.h>
#import "Swing.h"
#import "SwingCell.h"

#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/MobileCoreServices.h>

@interface MySwingsViewController : UITableViewController  <UITableViewDelegate, UITableViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate >

@property (nonatomic, strong) NSMutableArray *swings;

@property (copy,   nonatomic) NSURL *movieURL;
@property (strong, nonatomic) MPMoviePlayerController *movieController;

@property (strong, nonatomic) IBOutlet UIBarButtonItem *captureSwingbutton;
- (IBAction)captureSwing:(id)sender;

@end

和 MySwingsViewController.m

//  MySwingsViewController.m
#import "MySwingsViewController.h"

@interface MySwingsViewController ()
@end

@implementation MySwingsViewController

{
    NSArray *tableData; //just for test purposes
}

- (void)viewDidLoad
{
    NSLog(@"view did load");
    [super viewDidLoad];

    // Initialize table data
    tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
}

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 static NSString *CellIdentifier = @"SwingCell";
 SwingCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
 if (cell == nil) {
      cell = [[SwingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  }
cell.titleLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}

- (IBAction)captureSwing:(id)sender {
 UIImagePickerController *picker = [[UIImagePickerController alloc] init];
 picker.delegate = self;
 picker.allowsEditing = NO;
 picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    ...  // capture new clip
  }
 ...
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
   NSLog(@"picker did cancel");
   [picker dismissViewControllerAnimated:YES completion:NULL];
   [self.navigationController popViewControllerAnimated:YES];
}

cancel 被记录,picker 被关闭,返回 tableview,但数据没有重新显示...

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    不要调用 [self.navigationController popViewControllerAnimated:YES];这段代码实际上关闭了当前的 MySwingsViewController,我相信你的表格视图在 MySwingsViewController 上,对吧?

    【讨论】:

    • 是的..它是,删除它,但没有解决问题,表格视图显示任何数据
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-20
    • 2011-04-07
    • 2021-06-22
    • 1970-01-01
    • 2012-01-04
    相关资源
    最近更新 更多