ios – TableViewController得viewDidLoad沒有觸發

    我一直在關注這個 tutorial有一個滑出式菜單.我添加了一個TableViewController,它將顯示內容列表.由于某種原因,viewDidLoad沒有觸發.

    在本教程中,SideViewController控制將顯示哪個控制器,如果具有標識符為“showPhoto”得segue,它將加載特定圖像.

    // Set the photo if it navigates to the PhotoViewif ([segue.identifier isEqualToString:@"showPhoto"]) {    PhotoViewController *photoController = (PhotoViewController*)segue.destinationViewController;    NSString *photoFilename = [NSString stringWithFormat:@"%@_photo.jpg",[menuItems objectAtIndex:indexPath.row]];    photoController.photoFilename = photoFilename;}

    我想為TableViewController重新創建同樣得東西,并嘗試強制控制器得viewDidLoad,如此處所示Force viewDidLoad to fire on iOS,但它仍然無效:

    if ([segue.identifier isEqualToString:@"showList"]) {    TableViewController *tableController = (TableViewController*)segue.destinationViewController;    [tableController view];}

    TableViewController viewDidLoad:

    - (void)viewDidLoad{    [super viewDidLoad];    // Change button color    _sidebarButton.tintColor = [UIColor colorWithWhite:0.1f alpha:0.9f];    // Set the side bar button action. When it's tapped,it'll show up the sidebar.    _sidebarButton.target = self.revealViewController;    _sidebarButton.action = @selector(revealToggle:);    // Set the gesture    [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];    // Set this view controller object as the delegate and data source for the table view    self.listTableView.delegate = self;    self.listTableView.dataSource = self;    // Create array object and assign it to _feedItems variable    _feedItems = [[NSArray alloc] init];    // Create new HomeModel object and assign it to _homeModel variable    _homeModel = [[HomeModel alloc] init];    // Set this view controller object as the delegate for the home model object    _homeModel.delegate = self;    // Call the download items method of the home model object    [_homeModel downloadItems];}

    奇怪得是,正在使用得其他兩個控制器(PhotoViewController和MapViewController)按預期工作……也許有一些設置比我想念得還要多.

    我剛剛開始在iOS上,不幸得是無法解決這個問題.

    Project Download

    解決方法

    TableViewController存在多個問題(根據您共享得項目存檔)

    TableViewController.h

    @interface TableViewController : UIViewController <UITableViewDataSource,UITableViewDelegate,HomeModelProtocol>@property (weak,nonatomic) IBOutlet UIBarButtonItem *sidebarButton;@property (weak,nonatomic) IBOutlet UITableView *listTableView;@end

    應該:

    //subclass should be UITableViewController@interface TableViewController : UITableViewController <HomeModelProtocol>@property (weak,nonatomic) IBOutlet UIBarButtonItem *sidebarButton;//not needed//@property (weak,nonatomic) IBOutlet UITableView *listTableView;@end

    TableViewController.m

    在-viewDidLoad中,觀察:

    -(void)viewDidLoad{    //...    //crashes when adding gesture to a tableView (this is not part of the core problem    //but will be one if not handled) for now... comment it    //[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];    //not needed as it's done via IB (but this is not part of the problem)    //self.listTableView.delegate = self;    //self.listTableView.dataSource = self;    //...}

    故事板

    選擇那個UITableViewController:

    >將自定義類指定為TableViewController(通過Identity Inspector)
    >將頂部欄設置為半透明導航欄(通過屬性檢查器)
    >添加UINavigationItem
    >在其上添加一個UIBarButtonItem并將其設置為菜單(正如您在其他viewControllers中所做得那樣)

    >將IBOutlet對象sidebarButton連接到此UIBarButtonItem

    SidebarViewController.m

    在你得-prepareForSegue:sender:方法中,如果你沒有將數據傳遞給TableViewController那么你不需要做任何事情

    - (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender{    //...    if ([segue.identifier isEqualToString:@"showList"]) {        //TableViewController *tableController = (TableViewController*)segue.destinationViewController;        //this is definitely not needed whether you pass data or not        //[tableController view];    }    //...}

    以上是來客網為你收集整理得ios – TableViewController得viewDidLoad沒有觸發全部內容,希望內容能夠幫你解決ios – TableViewController得viewDidLoad沒有觸發所遇到得程序開發問題。

    如果覺得來客網網站內容還不錯,歡迎將來客網網站推薦給程序員好友。

    聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。
    發表評論
    更多 網友評論1 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 中文字幕在线无码一区| 性色av一区二区三区夜夜嗨| 日本一区二区在线| 国产乱子伦一区二区三区| 精品亚洲AV无码一区二区| 国产福利一区二区在线视频 | 国产一区二区三区免费在线观看| 一区二区三区在线|欧| 制服中文字幕一区二区| 国产成人精品久久一区二区三区av | 中文字幕一区一区三区| 伊人久久大香线蕉av一区| 国产精品无码不卡一区二区三区| 在线|一区二区三区四区| 亚洲av色香蕉一区二区三区| 亚洲天堂一区在线| 无码人妻精品一区二区三区99性| 久久免费精品一区二区| 国产麻豆剧果冻传媒一区| 精品无码中出一区二区| 97se色综合一区二区二区| 中文字幕日本精品一区二区三区| 国模精品一区二区三区视频 | 中文字幕乱码人妻一区二区三区| 国产精品 一区 在线| 日本免费一区二区三区最新vr| 亚洲香蕉久久一区二区三区四区 | 无码国产精品一区二区免费式直播| 国产一区二区高清在线播放| 国产亚洲情侣一区二区无| 国产一区二区三区小说| 国产一区二区三区免费观看在线| 日韩一区二区精品观看| 精品视频一区在线观看| 白丝爆浆18禁一区二区三区| 全国精品一区二区在线观看| 色欲AV无码一区二区三区| 日韩毛片一区视频免费| 精品一区二区无码AV| 国产乱码精品一区二区三区中文| 久久se精品动漫一区二区三区|